From c807d896517ecfa007f9230b2d28a3520808f3fe Mon Sep 17 00:00:00 2001 From: LE BERRE Mickael Date: Tue, 2 Jun 2026 12:29:58 +0200 Subject: [PATCH] Ajout du playbook de desinstall du monitoring Grafana --- Ansible/playbooks/uninstall_monitoring.yml | 170 +++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 Ansible/playbooks/uninstall_monitoring.yml diff --git a/Ansible/playbooks/uninstall_monitoring.yml b/Ansible/playbooks/uninstall_monitoring.yml new file mode 100644 index 0000000..87c7554 --- /dev/null +++ b/Ansible/playbooks/uninstall_monitoring.yml @@ -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