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)
|
||||
`promtail_version`: version to install
|
||||
`promtail_loki_server`: set loki server
|
||||
`promtail_loki_port`: set loki port
|
||||
`custom_server_config`: path to custom config witch replace all config with your own
|
||||
`custom_scrape_configs`: path to custom scrape configs
|
||||
- `promtail_version`: Promtail version to install
|
||||
- `promtail_loki_server`: address of the Loki server
|
||||
- `promtail_loki_port`: Loki listening port
|
||||
- `promtail_positions_path`: a YAML file containing last scraped positions in the logs (default: `/var/lib/promtail/positions.yaml`)
|
||||
- `promtail_custom_scrape_configs`: additional `scrape_configs` configuration
|
||||
- `promtail_add_var_logs`: scrape the entire `/var/logs` directory (default: `true`)
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
promtail_version: 2.7.3
|
||||
promtail_positions_path: /home/promtail/positions.yaml
|
||||
promtail_version: 3.6.3
|
||||
promtail_positions_path: /var/lib/promtail/positions.yaml
|
||||
promtail_http_port: 9080
|
||||
promtail_loki_server: localhost
|
||||
promtail_loki_port: 3100
|
||||
promtail_add_var_logs: true
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
---
|
||||
|
||||
- name: "Restart the Promtail daemon"
|
||||
- name: "Enable and restart the Promtail daemon"
|
||||
ansible.builtin.systemd:
|
||||
name: promtail
|
||||
state: restarted
|
||||
|
||||
|
||||
- name: "Reload the Promtail daemon configuration"
|
||||
ansible.builtin.systemd:
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
|
||||
@@ -2,7 +2,7 @@ galaxy_info:
|
||||
role_name: promtail
|
||||
namespace: genlab
|
||||
author: Danilkin Danila
|
||||
description: Installs Promtail
|
||||
description: Deploy Promtail
|
||||
|
||||
company: Genlab LLC
|
||||
license: MIT
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
hosts: all
|
||||
roles:
|
||||
- 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
|
||||
platforms:
|
||||
- name: ubuntu
|
||||
image: geerlingguy/docker-ubuntu2204-ansible:latest
|
||||
image: geerlingguy/docker-ubuntu2404-ansible:latest
|
||||
pre_build_image: true
|
||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||
volumes:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
|
||||
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"
|
||||
retries: 3
|
||||
delay: 1
|
||||
|
||||
@@ -7,19 +7,14 @@
|
||||
cache_valid_time: 3600
|
||||
|
||||
|
||||
- name: "Create the 'promtail' group"
|
||||
ansible.builtin.group:
|
||||
name: promtail
|
||||
state: present
|
||||
|
||||
|
||||
- name: "Create the 'promtail' user"
|
||||
ansible.builtin.user:
|
||||
name: promtail
|
||||
groups:
|
||||
- promtail
|
||||
- systemd-journal
|
||||
- adm
|
||||
- systemd-journal
|
||||
shell: /bin/false
|
||||
home: /var/lib/promtail
|
||||
state: present
|
||||
system: true
|
||||
|
||||
@@ -51,7 +46,6 @@
|
||||
changed_when: false
|
||||
|
||||
- name: "Assert version correctness"
|
||||
notify: "Restart the Promtail daemon"
|
||||
ansible.builtin.assert:
|
||||
that: "promtail_version in promtail_version_check.stdout"
|
||||
success_msg: "Expected Promtail version available ({{ promtail_version }})"
|
||||
@@ -59,6 +53,7 @@
|
||||
|
||||
rescue:
|
||||
- name: "Install Promtail if its not present"
|
||||
notify: "Enable and restart the Promtail daemon"
|
||||
ansible.builtin.unarchive:
|
||||
src: "https://github.com/grafana/loki/releases/download/v\
|
||||
{{ promtail_version }}/promtail-linux-amd64.zip"
|
||||
@@ -81,7 +76,7 @@
|
||||
|
||||
|
||||
- name: "Template the systemd unit file"
|
||||
notify: "Reload the Promtail daemon configuration"
|
||||
notify: "Enable and restart the Promtail daemon"
|
||||
ansible.builtin.template:
|
||||
src: promtail.service.j2
|
||||
dest: /etc/systemd/system/promtail.service
|
||||
@@ -89,19 +84,19 @@
|
||||
group: root
|
||||
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"
|
||||
notify: "Restart the Promtail daemon"
|
||||
notify: "Enable and restart the Promtail daemon"
|
||||
ansible.builtin.template:
|
||||
src: templates/promtail.yml.j2
|
||||
dest: /usr/local/bin/config-promtail.yml
|
||||
dest: /etc/promtail/config.yml
|
||||
owner: root
|
||||
group: root
|
||||
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]
|
||||
Type=simple
|
||||
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]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
{% if custom_server_config is defined %}
|
||||
{{ custom_server_config }}
|
||||
{% else %}
|
||||
---
|
||||
server:
|
||||
http_listen_port: {{ promtail_http_port }}
|
||||
grpc_listen_port: 0
|
||||
{% endif %}
|
||||
positions:
|
||||
filename: {{ promtail_positions_path }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user