1
0
Fork 0
mirror of https://gitlab.com/s3lph/ansible-collection-prometheus synced 2024-10-23 11:56:59 +02:00
ansible-collection-prometheus/roles/prometheus/tasks/prometheus.yml
2021-11-06 05:22:17 +01:00

35 lines
1.3 KiB
YAML

---
- name: render /etc/prometheus/prometheus.yml
ansible.builtin.template:
src: etc/prometheus/prometheus.yml.j2
dest: /etc/prometheus/prometheus.yml
owner: root
group: root
mode: 0644
validate: /usr/bin/promtool check config %s
vars:
jobs: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | list }}"
notify: restart prometheus
- name: render /etc/prometheus/alert_rules.yml
ansible.builtin.copy:
src: etc/prometheus/alert_rules.yml.j2
dest: /etc/prometheus/alert_rules.yml
owner: root
group: root
mode: 0644
validate: /usr/bin/promtool check rules %s
vars:
groups: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | map(attribute='group') | unique | default([prometheus_job_default_group_name]) }}"
jobs: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | list }}"
notify: restart prometheus
- name: render /etc/default/prometheus
ansible.builtin.template:
src: etc/default/prometheus.j2
path: /etc/default/prometheus
owner: root
group: root
mode: 0644
notify: restart prometheus