templier-ansible/roles/prometheus/tasks/main.yml
Yohann D'ANELLO 2a5f6621b6
Add monitoring
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-06-08 16:59:10 +02:00

43 lines
1020 B
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/alert.rules.yml.j2
dest: /etc/prometheus/alert.rules.yml
mode: 0644
notify: Restart Prometheus
# We don't need to restart Prometheus when updating nodes
- name: Configure Prometheus targets
copy:
content: "{{ [{'targets': item.value.targets}] | to_nice_json }}\n"
dest: "/etc/prometheus/{{ item.value.file }}"
mode: 0644
loop: "{{ prometheus | dict2items }}"
- 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