Skip to content

Commit 5ab5a64

Browse files
authored
add wazuh purge playbook (#2001)
Add wazuh purge playbook and update docs
1 parent 19d00a9 commit 5ab5a64

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

doc/source/configuration/wazuh.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,13 @@ Verification
421421
The Wazuh agents should register with the Wazuh manager. This can be verified via the agents page in Wazuh Portal.
422422
Check CIS benchmark output in agent section.
423423

424+
Wazuh manager removal
425+
---------------------
426+
427+
The following playbook can be used to purge all Wazuh manager components from a host. This is particularly useful for Wazuh manager servers that are not hosted on an infra-vm.
428+
429+
``kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/tools/wazuh-manager-purge.yml``
430+
424431
Additional resources
425432
--------------------
426433

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
# This is the playbook version of the wazuh purge tool from:
3+
# https://github.com/stackhpc/wazuh-server-purge
4+
5+
- name: Purge Wazuh Server Components
6+
hosts: wazuh-manager
7+
become: true
8+
become_user: root
9+
tasks:
10+
# Dashboard
11+
- name: Disable and stop wazuh-dashboard service
12+
ansible.builtin.systemd_service:
13+
name: wazuh-dashboard
14+
state: stopped
15+
enabled: no
16+
daemon_reload: true
17+
register: svc_result
18+
failed_when:
19+
- svc_result.failed
20+
- "'Could not find the requested service' not in svc_result.msg"
21+
22+
- name: Remove wazuh-dashboard and files
23+
ansible.builtin.package:
24+
name: wazuh-dashboard
25+
state: absent
26+
27+
- name: Remove wazuh-dashboard directories
28+
ansible.builtin.file:
29+
path: "{{ item }}"
30+
state: absent
31+
loop:
32+
- /var/lib/wazuh-dashboard
33+
- /usr/share/wazuh-dashboard
34+
- /etc/wazuh-dashboard
35+
# Manager
36+
- name: Remove wazuh-manager service
37+
ansible.builtin.systemd_service:
38+
name: wazuh-manager
39+
state: stopped
40+
enabled: no
41+
daemon_reload: true
42+
register: svc_result
43+
failed_when:
44+
- svc_result.failed
45+
- "'Could not find the requested service' not in svc_result.msg"
46+
47+
- name: Remove wazuh-manager and files
48+
ansible.builtin.package:
49+
name: wazuh-manager
50+
state: absent
51+
52+
- name: Remove wazuh-manager directories
53+
ansible.builtin.file:
54+
path: /var/ossec
55+
state: absent
56+
# Filebeat
57+
- name: Disable and stop filebeat service
58+
ansible.builtin.systemd_service:
59+
name: filebeat
60+
state: stopped
61+
enabled: no
62+
daemon_reload: true
63+
register: svc_result
64+
failed_when:
65+
- svc_result.failed
66+
- "'Could not find the requested service' not in svc_result.msg"
67+
68+
- name: Remove filebeat and files
69+
ansible.builtin.package:
70+
name: filebeat
71+
state: absent
72+
73+
- name: Remove filebeat directories
74+
ansible.builtin.file:
75+
path: "{{ item }}"
76+
state: absent
77+
loop:
78+
- /var/lib/filebeat
79+
- /usr/share/filebeat
80+
- /etc/filebeat
81+
# Indexer
82+
- name: Disable and stop wazuh-indexer service
83+
ansible.builtin.systemd_service:
84+
name: wazuh-indexer
85+
state: stopped
86+
enabled: no
87+
daemon_reload: true
88+
register: svc_result
89+
failed_when:
90+
- svc_result.failed
91+
- "'Could not find the requested service' not in svc_result.msg"
92+
93+
- name: Remove wazuh-indexer and files
94+
ansible.builtin.package:
95+
name: wazuh-indexer
96+
state: absent
97+
98+
- name: Remove wazuh-indexer directories
99+
ansible.builtin.file:
100+
path: "{{ item }}"
101+
state: absent
102+
loop:
103+
- /var/lib/wazuh-indexer
104+
- /usr/share/wazuh-indexer
105+
- /etc/wazuh-indexer

0 commit comments

Comments
 (0)