2021-02-10 20:42:37 +01:00
|
|
|
---
|
|
|
|
- name: Install Prometheus
|
|
|
|
apt:
|
|
|
|
update_cache: true
|
|
|
|
name:
|
|
|
|
- prometheus
|
|
|
|
register: apt_result
|
|
|
|
retries: 3
|
|
|
|
until: apt_result is succeeded
|
|
|
|
|
|
|
|
- name: Configure Prometheus
|
|
|
|
template:
|
2021-04-01 09:42:31 +02:00
|
|
|
src: "{{ item }}.j2"
|
2021-02-10 20:42:37 +01:00
|
|
|
dest: "/etc/prometheus/{{ item }}"
|
2021-04-01 18:15:09 +02:00
|
|
|
owner: prometheus
|
|
|
|
group: prometheus
|
2021-04-01 09:42:31 +02:00
|
|
|
mode: u=r,g=r,o=
|
2021-02-10 20:42:37 +01:00
|
|
|
loop:
|
2021-04-01 09:42:31 +02:00
|
|
|
- prometheus.yml
|
2021-02-10 20:42:37 +01:00
|
|
|
- alert.rules.yml
|
2021-04-01 09:42:31 +02:00
|
|
|
notify: Restart Prometheus
|
2021-02-10 20:42:37 +01:00
|
|
|
|
|
|
|
# We don't need to restart Prometheus when updating nodes
|
|
|
|
- name: Configure Prometheus Federate devices
|
|
|
|
copy:
|
2021-03-06 00:44:22 +01:00
|
|
|
content: "{{ [{'targets': prometheus_targets }] | to_nice_json }}"
|
2021-02-10 20:42:37 +01:00
|
|
|
dest: /etc/prometheus/targets.json
|
|
|
|
mode: 0644
|
|
|
|
when: prometheus_targets is defined
|
|
|
|
|
|
|
|
- name: Activate prometheus service
|
|
|
|
systemd:
|
|
|
|
name: prometheus
|
|
|
|
enabled: true
|
|
|
|
state: started
|
|
|
|
|
2021-03-06 04:48:39 +01:00
|
|
|
- include_role:
|
|
|
|
name: update_motd
|
|
|
|
vars:
|
|
|
|
motd_messages:
|
|
|
|
- key: 05-prometheus-federate
|
|
|
|
message: >-
|
|
|
|
Prometheus (en configuration fédération) est déployé sur cette
|
|
|
|
machine (voir /etc/prometheus)
|
2021-03-06 00:44:22 +01:00
|
|
|
...
|