Merge pull request #68 from corvus-migratorius/fix-promtail
Fix the promtail deployment role
This commit is contained in:
@@ -10,11 +10,12 @@ Role Variables
|
|||||||
--------------
|
--------------
|
||||||
|
|
||||||
(all optional)
|
(all optional)
|
||||||
`promtail_version`: version to install
|
- `promtail_version`: Promtail version to install
|
||||||
`promtail_loki_server`: set loki server
|
- `promtail_loki_server`: address of the Loki server
|
||||||
`promtail_loki_port`: set loki port
|
- `promtail_loki_port`: Loki listening port
|
||||||
`custom_server_config`: path to custom config witch replace all config with your own
|
- `promtail_positions_path`: a YAML file containing last scraped positions in the logs (default: `/var/lib/promtail/positions.yaml`)
|
||||||
`custom_scrape_configs`: path to custom scrape configs
|
- `promtail_custom_scrape_configs`: additional `scrape_configs` configuration
|
||||||
|
- `promtail_add_var_logs`: scrape the entire `/var/logs` directory (default: `true`)
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
promtail_version: 2.7.3
|
promtail_version: 3.6.3
|
||||||
promtail_positions_path: /home/promtail/positions.yaml
|
promtail_positions_path: /var/lib/promtail/positions.yaml
|
||||||
promtail_http_port: 9080
|
promtail_http_port: 9080
|
||||||
promtail_loki_server: localhost
|
|
||||||
promtail_loki_port: 3100
|
promtail_loki_port: 3100
|
||||||
promtail_add_var_logs: true
|
promtail_add_var_logs: true
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
- name: "Enable and restart the Promtail daemon"
|
||||||
- name: "Restart the Promtail daemon"
|
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: promtail
|
name: promtail
|
||||||
state: restarted
|
state: restarted
|
||||||
|
enabled: true
|
||||||
|
|
||||||
- name: "Reload the Promtail daemon configuration"
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ galaxy_info:
|
|||||||
role_name: promtail
|
role_name: promtail
|
||||||
namespace: genlab
|
namespace: genlab
|
||||||
author: Danilkin Danila
|
author: Danilkin Danila
|
||||||
description: Installs Promtail
|
description: Deploy Promtail
|
||||||
|
|
||||||
company: Genlab LLC
|
company: Genlab LLC
|
||||||
license: MIT
|
license: MIT
|
||||||
|
|||||||
@@ -3,3 +3,5 @@
|
|||||||
hosts: all
|
hosts: all
|
||||||
roles:
|
roles:
|
||||||
- role: genlab.common.promtail
|
- role: genlab.common.promtail
|
||||||
|
promtail_version: 3.6.3
|
||||||
|
promtail_loki_server: localhost # required, but doesn't do anything in these tests
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ driver:
|
|||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
- name: ubuntu
|
- name: ubuntu
|
||||||
image: geerlingguy/docker-ubuntu2204-ansible:latest
|
image: geerlingguy/docker-ubuntu2404-ansible:latest
|
||||||
pre_build_image: true
|
pre_build_image: true
|
||||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
|
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
|
||||||
extensions: ['yml']
|
extensions: ['yml']
|
||||||
|
|
||||||
# kics-scan ignore-block - kics doesn't like http but it's localhost so it's not important
|
# kics-scan ignore-block - kics doesn't like HTTP but on localhost it's not important
|
||||||
- name: "Sanity check the Promtail daemon"
|
- name: "Sanity check the Promtail daemon"
|
||||||
retries: 3
|
retries: 3
|
||||||
delay: 1
|
delay: 1
|
||||||
|
|||||||
@@ -7,19 +7,14 @@
|
|||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
|
|
||||||
|
|
||||||
- name: "Create the 'promtail' group"
|
|
||||||
ansible.builtin.group:
|
|
||||||
name: promtail
|
|
||||||
state: present
|
|
||||||
|
|
||||||
|
|
||||||
- name: "Create the 'promtail' user"
|
- name: "Create the 'promtail' user"
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: promtail
|
name: promtail
|
||||||
groups:
|
groups:
|
||||||
- promtail
|
|
||||||
- systemd-journal
|
|
||||||
- adm
|
- adm
|
||||||
|
- systemd-journal
|
||||||
|
shell: /bin/false
|
||||||
|
home: /var/lib/promtail
|
||||||
state: present
|
state: present
|
||||||
system: true
|
system: true
|
||||||
|
|
||||||
@@ -51,7 +46,6 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: "Assert version correctness"
|
- name: "Assert version correctness"
|
||||||
notify: "Restart the Promtail daemon"
|
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "promtail_version in promtail_version_check.stdout"
|
that: "promtail_version in promtail_version_check.stdout"
|
||||||
success_msg: "Expected Promtail version available ({{ promtail_version }})"
|
success_msg: "Expected Promtail version available ({{ promtail_version }})"
|
||||||
@@ -59,6 +53,7 @@
|
|||||||
|
|
||||||
rescue:
|
rescue:
|
||||||
- name: "Install Promtail if its not present"
|
- name: "Install Promtail if its not present"
|
||||||
|
notify: "Enable and restart the Promtail daemon"
|
||||||
ansible.builtin.unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "https://github.com/grafana/loki/releases/download/v\
|
src: "https://github.com/grafana/loki/releases/download/v\
|
||||||
{{ promtail_version }}/promtail-linux-amd64.zip"
|
{{ promtail_version }}/promtail-linux-amd64.zip"
|
||||||
@@ -81,7 +76,7 @@
|
|||||||
|
|
||||||
|
|
||||||
- name: "Template the systemd unit file"
|
- name: "Template the systemd unit file"
|
||||||
notify: "Reload the Promtail daemon configuration"
|
notify: "Enable and restart the Promtail daemon"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: promtail.service.j2
|
src: promtail.service.j2
|
||||||
dest: /etc/systemd/system/promtail.service
|
dest: /etc/systemd/system/promtail.service
|
||||||
@@ -89,19 +84,19 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: "Ensure '/etc/promtail' exists"
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/promtail
|
||||||
|
state: directory
|
||||||
|
owner: promtail
|
||||||
|
group: promtail
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
- name: "Template Promtail config file"
|
- name: "Template Promtail config file"
|
||||||
notify: "Restart the Promtail daemon"
|
notify: "Enable and restart the Promtail daemon"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: templates/promtail.yml.j2
|
src: templates/promtail.yml.j2
|
||||||
dest: /usr/local/bin/config-promtail.yml
|
dest: /etc/promtail/config.yml
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
|
||||||
|
|
||||||
- name: "Enable and start Promtail daemon"
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: promtail
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=promtail
|
User=promtail
|
||||||
ExecStart=/usr/bin/promtail -config.file /usr/local/bin/config-promtail.yml
|
ExecStart=/usr/bin/promtail -config.file /etc/promtail/config.yml
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
{% if custom_server_config is defined %}
|
---
|
||||||
{{ custom_server_config }}
|
|
||||||
{% else %}
|
|
||||||
server:
|
server:
|
||||||
http_listen_port: {{ promtail_http_port }}
|
http_listen_port: {{ promtail_http_port }}
|
||||||
grpc_listen_port: 0
|
grpc_listen_port: 0
|
||||||
{% endif %}
|
|
||||||
positions:
|
positions:
|
||||||
filename: {{ promtail_positions_path }}
|
filename: {{ promtail_positions_path }}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user