aim-web2.1.0rc9
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# checkmk_cleanup_scripts
|
||||
|
||||
Operator defaults are intentionally low-precedence; inventory and explicit run options may override them.
|
||||
|
||||
```yaml
|
||||
---
|
||||
|
||||
checkmk_linux_plugin_dir: /usr/lib/check_mk_agent/plugins
|
||||
checkmk_linux_local_dir: /usr/lib/check_mk_agent/local
|
||||
checkmk_linux_config_dir: /etc/check_mk
|
||||
checkmk_windows_plugin_dir: C:\ProgramData\checkmk\agent\plugins
|
||||
checkmk_windows_builtin_plugin_dir: C:\Program Files (x86)\checkmk\service\plugins
|
||||
checkmk_windows_local_dir: C:\ProgramData\checkmk\agent\local
|
||||
checkmk_monitoring_scripts_dir: '{{ lookup(''ansible.builtin.env'', ''AIM_CHECKMK_MONITORING_SCRIPTS_DIR'')
|
||||
| default(''/etc/checkmk_monitoring_scripts'', true) }}'
|
||||
checkmk_windows_scripts_dir: '{{ checkmk_monitoring_scripts_dir }}/Scripts Windows'
|
||||
checkmk_linux_scripts_dir: '{{ checkmk_monitoring_scripts_dir }}/Scripts Linux'
|
||||
checkmk_unifi_mode: auto
|
||||
want_linux_check_certificate: false
|
||||
want_windows_citrix: false
|
||||
want_windows_surebackup: false
|
||||
want_windows_backup: false
|
||||
want_windows_nsp_mailqueue: false
|
||||
want_windows_certificate: false
|
||||
want_windows_veeam_cloud_connect: false
|
||||
want_windows_veeam_backup: false
|
||||
checkmk_cleanup_enabled: false
|
||||
```
|
||||
|
||||
## Structured result integration
|
||||
|
||||
Current reporting behavior and field semantics are specified in
|
||||
[scripts/docs/OPERATION_RESULTS.md](../../scripts/docs/OPERATION_RESULTS.md).
|
||||
The calling catalog playbook owns publication; helper roles do not implicitly export
|
||||
arbitrary facts, module results or debug data. Existing defaults above retain their
|
||||
precedence. See the current validation/sanity documents before using the new candidate.
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
|
||||
checkmk_linux_plugin_dir: /usr/lib/check_mk_agent/plugins
|
||||
checkmk_linux_local_dir: /usr/lib/check_mk_agent/local
|
||||
checkmk_linux_config_dir: /etc/check_mk
|
||||
checkmk_windows_plugin_dir: C:\ProgramData\checkmk\agent\plugins
|
||||
checkmk_windows_builtin_plugin_dir: C:\Program Files (x86)\checkmk\service\plugins
|
||||
checkmk_windows_local_dir: C:\ProgramData\checkmk\agent\local
|
||||
checkmk_monitoring_scripts_dir: '{{ lookup(''ansible.builtin.env'', ''AIM_CHECKMK_MONITORING_SCRIPTS_DIR'')
|
||||
| default(''/etc/checkmk_monitoring_scripts'', true) }}'
|
||||
checkmk_windows_scripts_dir: '{{ checkmk_monitoring_scripts_dir }}/Scripts Windows'
|
||||
checkmk_linux_scripts_dir: '{{ checkmk_monitoring_scripts_dir }}/Scripts Linux'
|
||||
checkmk_unifi_mode: auto
|
||||
want_linux_check_certificate: false
|
||||
want_windows_citrix: false
|
||||
want_windows_surebackup: false
|
||||
want_windows_backup: false
|
||||
want_windows_nsp_mailqueue: false
|
||||
want_windows_certificate: false
|
||||
want_windows_veeam_cloud_connect: false
|
||||
want_windows_veeam_backup: false
|
||||
checkmk_cleanup_enabled: false
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
- name: Cleanup | Remove obsolete managed local check
|
||||
ansible.builtin.file:
|
||||
path: '{{ checkmk_linux_local_dir }}/{{ item }}'
|
||||
state: absent
|
||||
loop: '{{ _checkmk_remove_paths }}'
|
||||
register: _aim_cleanup_files
|
||||
- name: Cleanup | Remove UniFi configuration only when UniFi is disabled
|
||||
ansible.builtin.file:
|
||||
path: '{{ checkmk_linux_config_dir }}/unifi.cfg'
|
||||
state: absent
|
||||
when: _checkmk_unifi_effective == 'disabled'
|
||||
diff: false
|
||||
no_log: true
|
||||
register: _aim_cleanup_unifi
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
- 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) }}"
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
- name: Cleanup | Remove obsolete managed local check or legacy local plugin copy
|
||||
ansible.windows.win_file:
|
||||
path: '{{ checkmk_windows_local_dir }}\{{ item }}'
|
||||
state: absent
|
||||
loop: '{{ _checkmk_remove_paths }}'
|
||||
register: _aim_cleanup_local_files
|
||||
|
||||
- name: Cleanup | Remove obsolete managed custom plugin
|
||||
ansible.windows.win_file:
|
||||
path: '{{ checkmk_windows_plugin_dir }}\{{ item }}'
|
||||
state: absent
|
||||
loop: >-
|
||||
{{ _checkmk_obsolete_scripts
|
||||
| selectattr('destination', 'defined')
|
||||
| selectattr('destination', 'equalto', 'custom_plugin')
|
||||
| map(attribute='filename') | list }}
|
||||
register: _aim_cleanup_custom_plugin_files
|
||||
|
||||
- name: Cleanup | Remove obsolete known legacy built-in plugin copy
|
||||
ansible.windows.win_file:
|
||||
path: '{{ checkmk_windows_builtin_plugin_dir }}\{{ item }}'
|
||||
state: absent
|
||||
loop: >-
|
||||
{{ _checkmk_remove_paths
|
||||
| select('in', ['veeam_o365_status.ps1', 'veeam_backup_status.ps1'])
|
||||
| list }}
|
||||
register: _aim_cleanup_builtin_files
|
||||
|
||||
- name: Cleanup | Combine Windows cleanup results
|
||||
ansible.builtin.set_fact:
|
||||
_aim_cleanup_files:
|
||||
results: >-
|
||||
{{ (_aim_cleanup_local_files.results | default([]))
|
||||
+ (_aim_cleanup_custom_plugin_files.results | default([]))
|
||||
+ (_aim_cleanup_builtin_files.results | default([])) }}
|
||||
Reference in New Issue
Block a user