51 lines
1.3 KiB
YAML
51 lines
1.3 KiB
YAML
---
|
|
- name: Install Prometheus
|
|
apt:
|
|
update_cache: true
|
|
name:
|
|
- prometheus
|
|
- prometheus-snmp-exporter
|
|
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 adm only
|
|
when:
|
|
- ansible_lsb.codename == 'buster'
|
|
lineinfile:
|
|
path: /etc/default/prometheus-snmp-exporter
|
|
regexp: '^ARGS='
|
|
line: "ARGS=\"--web.listen-address={{ ansible_fqdn }}: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 SNMP devices
|
|
copy:
|
|
content: "{{ prometheus_snmp_targets | to_nice_json }}"
|
|
dest: /etc/prometheus/targets_snmp.json
|
|
|
|
- name: Activate prometheus service
|
|
systemd:
|
|
name: prometheus
|
|
enabled: yes
|
|
state: started
|