Files
configpolicy/roles/promtail/tasks/deploy.yml
Dustin C. Hatch 19009bde1a promtail: Role/Playbook to deploy Promtail
Promtail is the log sending client for Grafana Loki.  For traditional
Linux systems, an RPM package is available from upstream, making
installation fairly simple.  Configuration is stored in a YAML file, so
again, it's straightforward to configure via Ansible variables.  Really,
the only interesting step is adding the _promtail_ user, which is
created by the RPM package, to the _systemd-journal_ group, so that
Promtail can read the systemd journal files.
2024-02-22 19:23:31 -06:00

65 lines
1.2 KiB
YAML

- name: ensure promtail user is a member of systemd-journal group
user:
name: promtail
system: true
groups: systemd-journal
append: true
shell: /bin/false
state: present
tags:
- user
- name: ensure promtail is configured
copy:
content: |
{{ promtail_config | to_nice_yaml(indent=2) }}
dest: /etc/promtail/config.yml
mode: u=rw,go=r
owner: root
group: root
notify:
- reload promtail
tags:
- config
- name: ensure promtail ca certificate is set
copy:
content: |-
{{ promtail_ca }}
dest: /etc/promtail/ca.crt
owner: root
group: root
mode: u=rw,go=r
notify:
- reload promtail
tags:
- config
- cert
- name: ensure promtail service starts at boot
service:
name: promtail
enabled: true
tags:
- service
- name: ensure promtail is running
service:
name: promtail
state: started
tags:
- service
- name: ensure promtail http port is open in the firewall
firewalld:
port: >-
{{ promtail_config.server.http_listen_port }}/tcp
permanent: true
immediate: true
state: enabled
when: >-
promtail_config.server.http_listen_port|d(0) > 0
and host_uses_firewalld|d(true)
tags:
- firewall