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: 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:
|
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
|
|
|
|
|
|
|
|
- name: Indicate role in motd
|
|
|
|
template:
|
|
|
|
src: update-motd.d/05-service.j2
|
|
|
|
dest: /etc/update-motd.d/05-prometheus
|
|
|
|
mode: 0755
|
2021-03-06 00:44:22 +01:00
|
|
|
...
|