49 lines
1.1 KiB
YAML
49 lines
1.1 KiB
YAML
---
|
|
- name: Install Prometheus
|
|
apt:
|
|
update_cache: true
|
|
name:
|
|
- prometheus
|
|
register: apt_result
|
|
retries: 3
|
|
until: apt_result is succeeded
|
|
|
|
- name: Configure Prometheus
|
|
template:
|
|
src: prometheus/prometheus.yml.j2
|
|
dest: /etc/prometheus/prometheus.yml
|
|
mode: 0644
|
|
notify: Restart Prometheus
|
|
|
|
- name: Configure Prometheus alert rules
|
|
template:
|
|
src: "prometheus/{{ item }}.j2"
|
|
dest: "/etc/prometheus/{{ item }}"
|
|
mode: 0644
|
|
notify: Restart Prometheus
|
|
loop:
|
|
- alert.rules.yml
|
|
|
|
# We don't need to restart Prometheus when updating nodes
|
|
- name: Configure Prometheus Federate devices
|
|
copy:
|
|
content: "{{ [{'targets': prometheus_targets }] | to_nice_json }}"
|
|
dest: /etc/prometheus/targets.json
|
|
mode: 0644
|
|
when: prometheus_targets is defined
|
|
|
|
- name: Activate prometheus service
|
|
systemd:
|
|
name: prometheus
|
|
enabled: true
|
|
state: started
|
|
|
|
- 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)
|
|
...
|