mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Implemented defrost timer
This commit is contained in:
@@ -51,7 +51,9 @@ def stop_timer(service):
|
||||
"""
|
||||
Stop and disable a systemd timer for a service if it exists.
|
||||
"""
|
||||
if service_file_exists(service, "timer"):
|
||||
if service == "system-maintenance-service-defrost":
|
||||
print(f"Ignore: {service}")
|
||||
elif service_file_exists(service, "timer"):
|
||||
timer_name = f"{service}.timer"
|
||||
subprocess.run(['systemctl', 'stop', timer_name])
|
||||
subprocess.run(['systemctl', 'disable', timer_name])
|
||||
|
@@ -0,0 +1,6 @@
|
||||
- name: "restart system-maintenance-service-defrost.timer"
|
||||
systemd:
|
||||
name: system-maintenance-service-defrost.timer
|
||||
state: restarted
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
@@ -20,4 +20,13 @@
|
||||
|
||||
- name: "set variable to prevent loading when action status didn't change"
|
||||
set_fact:
|
||||
maintenance_service_freeze_action_last: "{{system_maintenance_service_freeze_action}}"
|
||||
maintenance_service_freeze_action_last: "{{system_maintenance_service_freeze_action}}"
|
||||
|
||||
- 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
|
||||
when: run_once_system_maintenance_service_freeze is not defined
|
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=starts system-maintenance-service-defrost.service
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{on_calendar_defrost}}
|
||||
RandomizedDelaySec={{randomized_delay_sec}}
|
||||
Persistent=false
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
@@ -4,4 +4,5 @@ OnFailure=systemd-notifier@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} {{item}} {{ system_maintenance_services | join(",") }}'
|
||||
ExecPreStart=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} {{item}} "{{ system_maintenance_services + [item] }}"'
|
||||
ExecStart=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} {{item}} "{{ system_maintenance_services }}"'
|
Reference in New Issue
Block a user