43 lines
1.9 KiB
YAML
43 lines
1.9 KiB
YAML
|
|
- name: Cleanup | Validate opt-in
|
|
ansible.builtin.assert:
|
|
that:
|
|
- (checkmk_cleanup_enabled) is boolean or (checkmk_cleanup_enabled | string | lower) in ['true',
|
|
'false']
|
|
fail_msg: checkmk_cleanup_enabled must be boolean.
|
|
quiet: true
|
|
- name: Cleanup | Build obsolete paths
|
|
ansible.builtin.set_fact:
|
|
_checkmk_remove_paths: "{{ _checkmk_obsolete_scripts | map(attribute='filename') | list }}"
|
|
- name: Cleanup | Candidate files
|
|
ansible.builtin.debug:
|
|
msg:
|
|
directory: "{{ checkmk_windows_local_dir if ansible_facts.os_family == 'Windows' else checkmk_linux_local_dir
|
|
}}"
|
|
files: '{{ _checkmk_remove_paths }}'
|
|
unifi_config: "{{ 'remove only when disabled' if ansible_facts.os_family != 'Windows' and _checkmk_unifi_effective
|
|
== 'disabled' else 'retained' }}"
|
|
mode: "{{ 'DELETE APPROVED' if checkmk_cleanup_enabled | bool else 'PREVIEW ONLY' }}"
|
|
- name: Cleanup | linux
|
|
ansible.builtin.include_tasks: linux.yml
|
|
when:
|
|
- checkmk_cleanup_enabled | bool
|
|
- ansible_facts.os_family != 'Windows'
|
|
- name: Cleanup | windows
|
|
ansible.builtin.include_tasks: windows.yml
|
|
when:
|
|
- checkmk_cleanup_enabled | bool
|
|
- ansible_facts.os_family == 'Windows'
|
|
- name: AIM | Publish operation result
|
|
ansible.builtin.set_stats:
|
|
per_host: true
|
|
aggregate: false
|
|
data:
|
|
aim_output:
|
|
protocol: aim_output_v1
|
|
schema: managed_cleanup_preview_v1
|
|
data: "{{ _checkmk_remove_paths | aim_report_cleanup(checkmk_windows_local_dir if ansible_facts.os_family
|
|
== 'Windows' else checkmk_linux_local_dir, _aim_cleanup_files | default({}), _checkmk_unifi_effective
|
|
if ansible_facts.os_family != 'Windows' else 'not_applicable', _aim_cleanup_unifi | default({}), checkmk_cleanup_enabled
|
|
| bool, ansible_check_mode) }}"
|