Ajout du playbook de desinstall du monitoring Grafana

This commit is contained in:
LE BERRE Mickael 2026-06-02 12:29:58 +02:00
parent e1c81bc354
commit c807d89651

View file

@ -0,0 +1,170 @@
# Désinstaller tous les agents (comportement par défaut)
#ansible-playbook -i inventaire.yml playbooks/uninstall_monitoring.yml
# Désinstaller uniquement promtail
#ansible-playbook -i inventaire.yml playbooks/uninstall_monitoring.yml --tags promtail
# Désinstaller uniquement node_exporter
#ansible-playbook -i inventaire.yml playbooks/uninstall_monitoring.yml --tags node_exporter
# Désinstaller promtail et prometheus (mais pas node_exporter)
#ansible-playbook -i inventaire.yml playbooks/uninstall_monitoring.yml --tags "promtail,prometheus"
# Dryrun, permet de voir les changements
#ansible-playbook -i inventaire.yml playbook/uninstall_monitoring.yml --check
---
- name: Uninstall legacy monitoring agents (promtail, node_exporter, prometheus-agent)
hosts: all
become: yes
tasks:
# ====================
# 1. Stop services
# ====================
- name: Stop promtail service
systemd:
name: promtail
state: stopped
ignore_errors: yes
tags:
- promtail
- name: Stop node_exporter service
systemd:
name: node_exporter
state: stopped
ignore_errors: yes
tags:
- node_exporter
- name: Stop prometheus-agent service
systemd:
name: prometheus-agent
state: stopped
ignore_errors: yes
tags:
- prometheus
# ====================
# 2. Disable services
# ====================
- name: Disable promtail service
systemd:
name: promtail
enabled: no
ignore_errors: yes
tags:
- promtail
- name: Disable node_exporter service
systemd:
name: node_exporter
enabled: no
ignore_errors: yes
tags:
- node_exporter
- name: Disable prometheus-agent service
systemd:
name: prometheus-agent
enabled: no
ignore_errors: yes
tags:
- prometheus
# ====================
# 3. Remove systemd service files
# ====================
- name: Remove promtail systemd service file
file:
path: /etc/systemd/system/promtail.service
state: absent
tags:
- promtail
- name: Remove node_exporter systemd service file
file:
path: /etc/systemd/system/node_exporter.service
state: absent
tags:
- node_exporter
- name: Remove prometheus-agent systemd service file
file:
path: /etc/systemd/system/prometheus-agent.service
state: absent
tags:
- prometheus
# ====================
# 4. Reload systemd daemon
# ====================
- name: Reload systemd daemon
systemd:
daemon_reload: yes
tags:
- always
# ====================
# 5. Remove directories
# ====================
- name: Remove promtail directory
file:
path: /appli/cimut/promtail
state: absent
tags:
- promtail
- name: Remove node_exporter directory
file:
path: /appli/cimut/prometheus/node_exporter
state: absent
tags:
- node_exporter
- name: Remove prometheus directory
file:
path: /appli/cimut/prometheus
state: absent
tags:
- prometheus
# ====================
# 6. Remove system users
# ====================
- name: Remove promtail user
user:
name: promtail
state: absent
remove: yes
ignore_errors: yes
tags:
- promtail
- name: Remove node-exporter user
user:
name: node-exporter
state: absent
remove: yes
ignore_errors: yes
tags:
- node_exporter
- name: Remove prometheus-agent user
user:
name: prometheus-agent
state: absent
remove: yes
ignore_errors: yes
tags:
- prometheus
# ====================
# 7. Final verification
# ====================
- name: Display completion message
debug:
msg: "Legacy monitoring agents have been successfully uninstalled. Grafana Alloy is now the active monitoring solution."
tags:
- always