43 lines
1.5 KiB
YAML
43 lines
1.5 KiB
YAML
---
|
|
|
|
- name: Linux | Require systemd service management
|
|
ansible.builtin.assert:
|
|
that:
|
|
- ansible_facts.service_mgr == 'systemd'
|
|
fail_msg: This Checkmk service policy requires systemd. No alternate service system is configured.
|
|
quiet: true
|
|
- name: Linux | Refresh systemd after package installation
|
|
ansible.builtin.systemd_service:
|
|
daemon_reload: true
|
|
when: _checkmk_package_install.changed | default(false) | bool
|
|
- name: Linux | Detect configured Checkmk units independently of running state
|
|
ansible.builtin.command:
|
|
argv:
|
|
- systemctl
|
|
- show
|
|
- --property=LoadState
|
|
- --value
|
|
- '{{ item }}'
|
|
loop:
|
|
- '{{ checkmk_linux_socket_name }}'
|
|
- '{{ checkmk_linux_service_name }}'
|
|
register: _checkmk_units
|
|
changed_when: false
|
|
failed_when: 'false'
|
|
check_mode: false
|
|
- name: Linux | Select the installed unit, preferring the socket
|
|
ansible.builtin.set_fact:
|
|
_checkmk_linux_units: '{{ _checkmk_units.results | selectattr(''stdout'', ''defined'') | selectattr(''stdout'',
|
|
''equalto'', ''loaded'') | map(attribute=''item'') | list }}'
|
|
- name: Linux | Require an installed Checkmk unit
|
|
ansible.builtin.assert:
|
|
that:
|
|
- _checkmk_linux_units | length > 0
|
|
fail_msg: No configured Checkmk socket/service unit was found. Verify installation and the unit names.
|
|
quiet: true
|
|
- name: Linux | Ensure Checkmk is enabled and running
|
|
ansible.builtin.systemd_service:
|
|
name: '{{ _checkmk_linux_units | first }}'
|
|
enabled: true
|
|
state: started
|