ansible/roles/prometheus/tasks/main.yml

51 lines
1.2 KiB
YAML
Raw Normal View History

2019-05-05 14:07:04 +02:00
---
- name: Install Prometheus
apt:
update_cache: true
2019-07-22 20:56:43 +02:00
name:
- prometheus
- prometheus-snmp-exporter
2019-05-05 14:07:04 +02:00
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:
2019-07-22 20:56:43 +02:00
src: "prometheus/{{ item }}.j2"
dest: "/etc/prometheus/{{ item }}"
2019-05-05 14:07:04 +02:00
notify: Restart Prometheus
2019-07-22 20:56:43 +02:00
loop:
- alert.rules.yml
- django.rules.yml
- name: Make Prometheus snmp-exporter listen on localhost only
lineinfile:
path: /etc/default/prometheus-snmp-exporter
regexp: '^ARGS='
line: "ARGS=\"--web.listen-address=127.0.0.1:9116\""
notify: Restart prometheus-snmp-exporter
2019-05-05 14:07:04 +02:00
# 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
2019-07-22 20:56:43 +02:00
- name: Activate prometheus service
systemd:
name: prometheus
2019-07-22 21:04:58 +02:00
enabled: true
2019-07-22 20:56:43 +02:00
state: started
- name: Indicate role in motd
template:
src: update-motd.d/05-service.j2
dest: /etc/update-motd.d/05-prometheus
mode: 0755