2023-12-13 19:02:07 +01:00
|
|
|
---
|
2023-12-13 19:36:06 +01:00
|
|
|
- name: create {{path_system_maintenance_service_freezer_script}}
|
2023-12-13 19:02:07 +01:00
|
|
|
copy:
|
|
|
|
src: system-maintenance-service-freezer.py
|
2023-12-13 19:36:06 +01:00
|
|
|
dest: "{{path_system_maintenance_service_freezer_script}}"
|
2023-12-13 21:14:08 +01:00
|
|
|
when: run_once_system_maintenance_service_freeze is not defined
|
2023-12-13 19:02:07 +01:00
|
|
|
|
2023-12-14 21:12:25 +01:00
|
|
|
- name: Configure system-maintenance-service for each action
|
|
|
|
loop:
|
|
|
|
- freeze
|
|
|
|
- defrost
|
|
|
|
template:
|
|
|
|
src: system-maintenance-service-freezer.service.j2
|
|
|
|
dest: "/etc/systemd/system/system-maintenance-service-{{ item }}.service"
|
|
|
|
notify: "reload system-maintenance-service-{{ item }}.service"
|
2023-12-13 21:14:08 +01:00
|
|
|
when: run_once_system_maintenance_service_freeze is not defined
|
|
|
|
|
|
|
|
- name: "restart system-maintenance-service.service"
|
|
|
|
systemd:
|
|
|
|
name: system-maintenance-service-{{system_maintenance_service_freeze_action}}.service
|
2023-12-14 00:15:01 +01:00
|
|
|
state: restarted
|
2023-12-13 21:14:08 +01:00
|
|
|
enabled: yes
|
|
|
|
daemon_reload: yes
|
|
|
|
when: maintenance_service_freeze_action_last is not defined or maintenance_service_freeze_action_last != system_maintenance_service_freeze_action
|
|
|
|
|
2023-12-14 19:06:57 +01:00
|
|
|
- name: create system-maintenance-service-defrost.timer
|
|
|
|
template:
|
|
|
|
src: system-maintenance-service-defrost.timer.j2
|
|
|
|
dest: "/etc/systemd/system/system-maintenance-service-defrost.timer"
|
|
|
|
register: system_maintenance_service_defrost_timer
|
|
|
|
changed_when: system_maintenance_service_defrost_timer.changed or activate_all_timers | bool
|
|
|
|
notify: restart system-maintenance-service-defrost.timer
|
2023-12-14 21:12:25 +01:00
|
|
|
when: run_once_system_maintenance_service_freeze is not defined
|
|
|
|
|
|
|
|
## Runtime Variable Setting
|
|
|
|
|
|
|
|
- name: run the system_maintenance_service_freezer tasks once
|
|
|
|
set_fact:
|
|
|
|
run_once_system_maintenance_service_freeze: true
|
|
|
|
when: run_once_system_maintenance_service_freeze is not defined
|
|
|
|
|
|
|
|
- name: "set variable to prevent loading when action status didn't change"
|
|
|
|
set_fact:
|
|
|
|
maintenance_service_freeze_action_last: "{{system_maintenance_service_freeze_action}}"
|