mirror of
https://gitlab.com/s3lph/ansible-collection-prometheus
synced 2024-10-23 11:56:59 +02:00
35 lines
1.3 KiB
YAML
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.template:
|
|
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:
|
|
alert_groups: "{{ hostvars[inventory_hostname] | dict2items | selectattr('key', 'match', '^prometheus_job_.+$') | map(attribute='value') | map(attribute='group', default=prometheus_default_group_name) | unique | list }}"
|
|
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
|
|
dest: /etc/default/prometheus
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
notify: restart prometheus
|