aboutsummaryrefslogtreecommitdiff
path: root/roles/services/monitoring/prometheus/nginx_exporter
diff options
context:
space:
mode:
Diffstat (limited to 'roles/services/monitoring/prometheus/nginx_exporter')
-rw-r--r--roles/services/monitoring/prometheus/nginx_exporter/defaults/main.yml4
-rw-r--r--roles/services/monitoring/prometheus/nginx_exporter/handlers/main.yml9
-rw-r--r--roles/services/monitoring/prometheus/nginx_exporter/tasks/main.yml44
3 files changed, 57 insertions, 0 deletions
diff --git a/roles/services/monitoring/prometheus/nginx_exporter/defaults/main.yml b/roles/services/monitoring/prometheus/nginx_exporter/defaults/main.yml
new file mode 100644
index 0000000..9d2b8a5
--- /dev/null
+++ b/roles/services/monitoring/prometheus/nginx_exporter/defaults/main.yml
@@ -0,0 +1,4 @@
1nginx_exporter_debian_package: prometheus-nginx-exporter
2nginx_exporter_fedora_package: golang-github-prometheus-node-exporter
3prometheus_server_ip: 192.168.88.32
4nginx_exporter_port: '9113'
diff --git a/roles/services/monitoring/prometheus/nginx_exporter/handlers/main.yml b/roles/services/monitoring/prometheus/nginx_exporter/handlers/main.yml
new file mode 100644
index 0000000..fe9a90d
--- /dev/null
+++ b/roles/services/monitoring/prometheus/nginx_exporter/handlers/main.yml
@@ -0,0 +1,9 @@
1- name: restart nginx
2 service:
3 name: nginx
4 state: restarted
5
6- name: restart nginx-exporter
7 service:
8 name: prometheus-nginx-exporter
9 state: started
diff --git a/roles/services/monitoring/prometheus/nginx_exporter/tasks/main.yml b/roles/services/monitoring/prometheus/nginx_exporter/tasks/main.yml
new file mode 100644
index 0000000..819f71e
--- /dev/null
+++ b/roles/services/monitoring/prometheus/nginx_exporter/tasks/main.yml
@@ -0,0 +1,44 @@
1- name: install package (Debian)
2 when: ansible_facts['distribution'] == "Debian"
3 package:
4 name: "{{ nginx_exporter_debian_package }}"
5
6- name: allow port
7 ufw:
8 rule: allow
9 direction: in
10 proto: tcp
11 src: "{{ prometheus_server_ip }}"
12 to_port: "{{ nginx_exporter_port }}"
13
14- name: copy defaults file
15 notify: restart nginx-exporter
16 copy:
17 src: "{{ nginx_exporter_defaults }}"
18 dest: /etc/default/prometheus-nginx-exporter
19 owner: root
20 group: root
21 mode: '0644'
22
23- name: deploy nginx configuration
24 notify: restart nginx
25 copy:
26 src: "{{ nginx_exporter_config }}"
27 dest: /etc/nginx/sites-available/metrics.conf
28 owner: root
29 group: root
30 mode: '0644'
31
32- name: symlink site
33 file:
34 src: /etc/nginx/sites-available/metrics.conf
35 dest: /etc/nginx/sites-enabled/metrics.conf
36 owner: root
37 group: root
38 state: link
39
40- name: enable service
41 systemd:
42 name: prometheus-nginx-exporter
43 enabled: yes
44 masked: no