ansible/roles/prometheus/tasks/main.yml

57 lines
1.3 KiB
YAML

---
- name: Install prometheus
apt:
name:
- prometheus
- name: Configure prometheus
template:
src: prometheus.yml.j2
dest: /etc/prometheus/prometheus.yml
owner: prometheus
group: prometheus
mode: u=rw,g=r,o=r
vars:
prometheus__config:
alerting:
alertmanagers:
- static_configs:
- targets: "{{ prometheus__alertmanager_targets }}"
rule_files:
- /etc/prometheus/rules.yml
scrape_configs: "{{ prometheus__scraping
| prometheus__convert_jobs }}"
notify:
- Restart prometheus
- name: Configure prometheus default
template:
src: default.j2
dest: /etc/default/prometheus
owner: root
group: root
mode: u=rw,g=r,o=r
notify:
- Restart prometheus
- name: Configure prometheus rules
template:
src: rules.yml.j2
dest: /etc/prometheus/rules.yml
owner: prometheus
group: prometheus
mode: u=rw,g=r,o=r
validate: "promtool check rules %s"
vars:
prometheus__rules:
groups: "{{ prometheus__alert_rules
| dict2items(key_name='name', value_name='rules') }}"
notify:
- Reload prometheus
- name: Enable prometheus
systemd:
name: prometheus
enabled: true
state: started
...