feat(monitoring): add grafana, prometheus, node_exporter roles

- grafana: postgres backend, provisioning (prometheus datasource + node/NUT dashboards)
- prometheus: native service, scrape config via host_vars, localhost bind
- node_exporter: host metrics exporter (localhost:9100)
This commit is contained in:
Clément Désiles
2026-09-05 17:24:08 +02:00
parent b94743567f
commit 12b81919c3
29 changed files with 1288 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
---
- name: Load OS-specific variables
ansible.builtin.include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_facts['os_family'] }}.yml"
- "debian.yml"
- name: Install Prometheus
ansible.builtin.package:
name: "{{ prometheus_package }}"
state: present
- name: Create Prometheus configuration directory
ansible.builtin.file:
path: "{{ prometheus_config_dir }}"
state: directory
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
mode: "0755"
- name: Create Prometheus data directory
ansible.builtin.file:
path: "{{ prometheus_data_dir }}"
state: directory
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
mode: "0750"
- name: Create Prometheus rules directory
ansible.builtin.file:
path: "{{ prometheus_config_dir }}/rules"
state: directory
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
mode: "0755"
when: prometheus_rule_files | length > 0
- name: Deploy Prometheus configuration
ansible.builtin.template:
src: prometheus.yml.j2
dest: "{{ prometheus_config_dir }}/prometheus.yml"
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
mode: "0644"
validate: "promtool check config %s"
notify: Restart Prometheus
- name: Deploy Prometheus environment file
ansible.builtin.template:
src: prometheus-env.conf.j2
dest: "{{ prometheus_args_file }}"
owner: root
group: root
mode: "0644"
notify: Restart Prometheus
- name: Enable and start Prometheus service
ansible.builtin.systemd:
name: "{{ prometheus_service }}"
enabled: true
state: started
- name: Deploy Nginx vhost configuration
ansible.builtin.template:
src: nginx-vhost.conf.j2
dest: "{{ nginx_conf_dir }}/prometheus.conf"
owner: root
group: root
mode: "0644"
when: prometheus_nginx_enabled
notify: Reload Nginx
- name: Remove Nginx vhost configuration
ansible.builtin.file:
path: "{{ nginx_conf_dir }}/prometheus.conf"
state: absent
when: not prometheus_nginx_enabled
notify: Reload Nginx