52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
---
|
|
- name: Install Prometheus
|
|
apt:
|
|
update_cache: true
|
|
name:
|
|
- prometheus
|
|
- prometheus-snmp-exporter
|
|
- snmp-mibs-downloader # To generate SNMP configuration
|
|
register: apt_result
|
|
retries: 3
|
|
until: apt_result is succeeded
|
|
|
|
- name: Configure Prometheus
|
|
template:
|
|
src: prometheus/prometheus.yml.j2
|
|
dest: /etc/prometheus/prometheus.yml
|
|
notify: Restart Prometheus
|
|
|
|
- name: Configure Prometheus alert rules
|
|
template:
|
|
src: prometheus/alert.rules.yml.j2
|
|
dest: /etc/prometheus/alert.rules.yml
|
|
notify: Restart Prometheus
|
|
|
|
# Doesn't work on Debian Stretch
|
|
- name: Make Prometheus snmp-exporter listen on localhost only
|
|
when:
|
|
- ansible_lsb.codename == 'buster'
|
|
lineinfile:
|
|
path: /etc/default/prometheus-snmp-exporter
|
|
regexp: '^ARGS='
|
|
line: "ARGS=\"--web.listen-address=127.0.0.1:9116\""
|
|
notify: Restart prometheus-snmp-exporter
|
|
|
|
# We don't need to restart Prometheus when updating nodes
|
|
- name: Configure Prometheus nodes
|
|
copy:
|
|
content: "{{ prometheus_targets | to_nice_json }}"
|
|
dest: /etc/prometheus/targets.json
|
|
|
|
# We don't need to restart Prometheus when updating nodes
|
|
- name: Configure Prometheus UPS SNMP devices
|
|
copy:
|
|
content: "{{ prometheus_ups_snmp_targets | to_nice_json }}"
|
|
dest: /etc/prometheus/targets_ups_snmp.json
|
|
|
|
- name: Activate prometheus service
|
|
systemd:
|
|
name: prometheus
|
|
enabled: yes
|
|
state: started
|