This repository has been archived on 2023-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
salt-states_old/promtail/init.sls

62 lines
1.7 KiB
Plaintext
Raw Normal View History

2023-03-30 07:42:35 +00:00
{%- set client_url = "http://loki.rre.nu:3100/loki/api/v1/push" %}
{%- set http_listen_port = 9080 %}
{%- set zone = "public" %}
Create promtail configuration folder:
file.directory:
- name: /etc/promtail
- user: root
- group: root
- mode: "0755"
Create promtail configuration:
file.managed:
- name: /etc/promtail/promtail.conf
- source: salt://promtail/files/promtail.conf.jinja
- template: jinja
- user: root
- group: root
- mode: "0644"
- require:
- file: Create promtail configuration folder
- context:
client_url: {{ client_url }}
http_listen_port: {{ http_listen_port }}
Define firewall service for promtail:
firewalld.service:
- name: promtail
- ports:
- {{ http_listen_port }}/tcp
adding fw service for promtail in {{ zone }} zone:
firewalld.present:
- name: {{ zone }}
- services:
- promtail
Create promtail container:
cmd.run:
2023-03-30 08:23:32 +00:00
- name: podman container create --name promtail -p {{ http_listen_port }}:{{ http_listen_port}} -v /etc/promtail:/etc/promtail:ro -v /var/log/journal:/var/log/journal:ro docker.io/grafana/promtail:latest -config.file=/etc/promtail/promtail.conf --client.external-labels=hostname={{ grains['fqdn'] }}
2023-03-30 07:42:35 +00:00
- unless: podman container exists promtail
Create promail unit file:
cmd.run:
- name: podman generate systemd --name promtail > /etc/systemd/system/promtail.service
- onchanges:
- cmd: Create promtail container
Run daeom-reload for promtail:
cmd.run:
- name: systemctl daemon-reload
- onchanges:
- cmd: Create promail unit file
start promail service:
service.running:
- name: promtail
- enable: true
- watch:
- cmd: Create promail unit file