Add monitoring

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
2021-06-08 16:59:10 +02:00
parent f7de61b6e2
commit 2a5f6621b6
31 changed files with 895 additions and 0 deletions

View File

@ -0,0 +1,10 @@
---
- name: Restart nginx
service:
name: nginx
state: restarted
- name: Restart prometheus-nginx-exporter
service:
name: prometheus-nginx-exporter
state: restarted

View File

@ -0,0 +1,33 @@
---
- name: Install prometheus-nginx-exporter
apt:
update_cache: true
name:
- nginx # Nginx may be not already installed
- prometheus-nginx-exporter
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Make prometheus-nginx-exporter listen on adm only
lineinfile:
path: /etc/default/prometheus-nginx-exporter
regexp: '^ARGS='
line: |
ARGS="-web.listen-address={{ prometheus_nginx_exporter.listen_addr }}:9117 -nginx.scrape-uri=http://[::1]:6424/stub_status"
notify:
- Restart nginx
- Restart prometheus-nginx-exporter
- name: Configure nginx
template:
src: nginx/status.j2
dest: /etc/nginx/sites-available/status
notify: Restart nginx
- name: Activate nginx site
file:
src: /etc/nginx/sites-available/status
dest: /etc/nginx/sites-enabled/status
state: link
notify: Restart nginx

View File

@ -0,0 +1,8 @@
{{ ansible_header | comment }}
server {
listen [::1]:6424;
location = /stub_status {
stub_status;
}
}