ansible/roles/prometheus_federate/tasks/main.yml

47 lines
1 KiB
YAML
Raw Normal View History

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:
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
mode: u=r,g=r,o=
2021-02-10 20:42:37 +01:00
loop:
- prometheus.yml
2021-02-10 20:42:37 +01:00
- alert.rules.yml
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:
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-04-17 17:37:45 +02:00
- name: Configure MOTD
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)
...