Add playbook to remove PatchMon agent (patch server retired)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
fa0bd81dd2
commit
ef7047f6bc
1 file changed
+36
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
# Remove the PatchMon agent (server patch.ki5bhv.com / 192.168.1.8 was retired).
|
||||||
|
- name: Remove PatchMon agent
|
||||||
|
hosts: linux
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: Check for PatchMon unit
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/systemd/system/patchmon-agent.service
|
||||||
|
register: patchmon_unit
|
||||||
|
|
||||||
|
- name: Stop and disable patchmon-agent
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: patchmon-agent
|
||||||
|
state: stopped
|
||||||
|
enabled: false
|
||||||
|
when: patchmon_unit.stat.exists
|
||||||
|
|
||||||
|
- name: Find PatchMon cron entries
|
||||||
|
ansible.builtin.find:
|
||||||
|
paths: /etc/cron.d
|
||||||
|
patterns: "patchmon*"
|
||||||
|
register: patchmon_cron
|
||||||
|
|
||||||
|
- name: Remove PatchMon files
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop: "{{ ['/etc/systemd/system/patchmon-agent.service', '/usr/local/bin/patchmon-agent', '/etc/patchmon']
|
||||||
|
+ (patchmon_cron.files | map(attribute='path') | list) }}"
|
||||||
|
register: patchmon_removed
|
||||||
|
|
||||||
|
- name: Reload systemd
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
daemon_reload: true
|
||||||
|
when: patchmon_removed is changed
|
||||||
Reference in new issue
Block a user