2021-09-05 21:32:21 +02:00
|
|
|
---
|
|
|
|
- name: Install Prometheus Components
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- prometheus
|
|
|
|
- prometheus-alertmanager
|
|
|
|
- prometheus-pushgateway
|
|
|
|
state: latest
|
|
|
|
update_cache: true
|
|
|
|
register: apt_result
|
|
|
|
retries: 3
|
|
|
|
until: apt_result is succeeded
|
2021-09-05 22:02:48 +02:00
|
|
|
|
|
|
|
- name: Ensure the alert folder exist
|
|
|
|
file:
|
|
|
|
path: /etc/prometheus/alerts
|
|
|
|
state: directory
|
|
|
|
group: prometheus
|
|
|
|
owner: prometheus
|
|
|
|
mode: u=rwx,g=rx,o=rx
|
|
|
|
|
2021-09-21 16:30:49 +02:00
|
|
|
- name: Generate certificate
|
|
|
|
include_role:
|
|
|
|
name: generate-cert
|
|
|
|
vars:
|
|
|
|
directory: /etc/prometheus/
|
|
|
|
cname: "prometheus-{{ lan_address }}"
|
|
|
|
owner: prometheus
|
|
|
|
group: prometheus
|
|
|
|
key_mode: u=rw,g=,o=
|
|
|
|
subject_alt_name: "IP:{{ lan_address }}"
|
|
|
|
# Need an equivalent to notify here
|
|
|
|
|
|
|
|
- name: Copy the CA cert
|
|
|
|
copy:
|
|
|
|
content: "{{ ca_cert }}"
|
|
|
|
dest: /etc/prometheus/ca.crt
|
|
|
|
notify: Restart prometheus
|
|
|
|
|
2021-09-05 22:02:48 +02:00
|
|
|
- name: Setup the prometheus config
|
|
|
|
template:
|
|
|
|
src: prometheus.yml
|
|
|
|
dest: /etc/prometheus/prometheus.yml
|
2021-09-06 00:55:47 +02:00
|
|
|
owner: prometheus
|
|
|
|
group: prometheus
|
2021-09-05 22:02:48 +02:00
|
|
|
mode: '0640'
|
2021-09-06 00:30:05 +02:00
|
|
|
notify: Restart prometheus
|
2021-09-05 22:02:48 +02:00
|
|
|
no_log: true
|
|
|
|
|
2021-09-21 12:04:22 +02:00
|
|
|
- name: Add node targets file
|
|
|
|
template:
|
|
|
|
src: node-targets.json
|
|
|
|
dest: /etc/prometheus/node-targets.json
|
|
|
|
owner: prometheus
|
|
|
|
group: prometheus
|
|
|
|
mode: '0640'
|
|
|
|
force: no
|
|
|
|
notify: Restart prometheus
|
|
|
|
no_log: true
|
|
|
|
|
|
|
|
- name: Setup the arguments for prometheus
|
2021-09-06 01:13:54 +02:00
|
|
|
template:
|
|
|
|
src: prometheus
|
|
|
|
dest: /etc/default/prometheus
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: '0644'
|
|
|
|
notify: Restart prometheus
|
|
|
|
vars:
|
|
|
|
args:
|
|
|
|
- name: web.listen-address
|
2021-09-06 01:16:09 +02:00
|
|
|
value: "{{ lan_address }}:9090"
|