2024-09-26 22:02:36 +00:00
|
|
|
---
|
|
|
|
- name: Template the system service
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: healthcheck@.service.j2
|
|
|
|
dest: /etc/systemd/system/healthcheck@.service
|
|
|
|
mode: "0644"
|
|
|
|
become: true
|
|
|
|
- name: Copy the system timer
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: healthcheck@.timer
|
|
|
|
dest: /etc/systemd/system/healthcheck@.timer
|
|
|
|
mode: "0644"
|
|
|
|
become: true
|
2024-10-06 18:47:59 +00:00
|
|
|
|
|
|
|
- name: Get all healthcheck timers
|
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "systemctl list-timers 'healthcheck@*' --all --output=json | jq -r '.[].unit'"
|
|
|
|
register: systemd_timers_result
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: Generate systemd timer names
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
healthcheck_systemd_timers: "{{ healthcheck_svc.checks | list_prefix_suffix('healthcheck@', '.timer') }}"
|
|
|
|
|
|
|
|
- name: Disable unused system timers
|
|
|
|
ansible.builtin.systemd_service:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
|
|
|
loop: "{{ systemd_timers_result.stdout_lines | difference(healthcheck_systemd_timers) }}"
|
|
|
|
become: true
|
|
|
|
|
2024-09-26 22:02:36 +00:00
|
|
|
- name: Enable the system timer
|
|
|
|
ansible.builtin.systemd_service:
|
2024-10-06 18:47:59 +00:00
|
|
|
name: "{{ item }}"
|
2024-09-26 22:02:36 +00:00
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
daemon_reload: true
|
2024-10-06 18:47:59 +00:00
|
|
|
loop: "{{ healthcheck_systemd_timers }}"
|
2024-09-26 22:02:36 +00:00
|
|
|
become: true
|