mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-22 04:31:13 +01:00
Solved more freezer bugs
This commit is contained in:
parent
234bab1805
commit
0b15b9c581
@ -4,5 +4,5 @@ OnFailure=systemd-notifier@%n.service cleanup-failed-docker-backups.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze "{{ system_maintenance_services | join(' ') }}" --ignore "{{system_maintenance_backup_services| join(' ') }}" --timeout "{{system_maintenance_timeout_backup_services}}"'
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_backup_services| join(' ') }} --timeout "{{system_maintenance_timeout_backup_services}}"'
|
||||||
ExecStart=/bin/sh -c '/usr/bin/python {{backup_docker_to_local_folder}}backup-docker-to-local.py && systemctl start system-maintenance-service-defrost.service'
|
ExecStart=/bin/sh -c '/usr/bin/python {{backup_docker_to_local_folder}}backup-docker-to-local.py && systemctl start system-maintenance-service-defrost.service'
|
@ -4,5 +4,5 @@ OnFailure=systemd-notifier@%n.service cleanup-failed-docker-backups.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze "{{ system_maintenance_services | join(' ') }}" --ignore "{{system_maintenance_backup_services| join(' ') }}" --timeout "{{system_maintenance_timeout_backup_services}}"'
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_backup_services| join(' ') }} --timeout "{{system_maintenance_timeout_backup_services}}"'
|
||||||
ExecStart=/bin/sh -c '/usr/bin/bash {{docker_backup_remote_to_local_folder}}backups-remote-to-local.sh && systemctl start system-maintenance-service-defrost.service'
|
ExecStart=/bin/sh -c '/usr/bin/bash {{docker_backup_remote_to_local_folder}}backups-remote-to-local.sh && systemctl start system-maintenance-service-defrost.service'
|
||||||
|
@ -4,5 +4,5 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze "{{ system_maintenance_services | join(' ') }}" --ignore "{{system_maintenance_cleanup_services| join(' ') }}" --timeout "{{system_maintenance_timeout_backup_services}}"'
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_cleanup_services| join(' ') }} --timeout "{{system_maintenance_timeout_backup_services}}"'
|
||||||
ExecStart=/bin/sh -c '/usr/bin/python {{docker_cleanup_backups}}cleanup-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} && systemctl start system-maintenance-service-defrost.service'
|
ExecStart=/bin/sh -c '/usr/bin/python {{docker_cleanup_backups}}cleanup-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} && systemctl start system-maintenance-service-defrost.service'
|
@ -4,5 +4,5 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze "{{ system_maintenance_services | join(' ') }}" --ignore "{{system_maintenance_cleanup_services| join(' ') }}" --timeout "{{system_maintenance_timeout_backup_services}}"'
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_cleanup_services| join(' ') }} --timeout "{{system_maintenance_timeout_backup_services}}"'
|
||||||
ExecStart=/bin/sh -c '/bin/bash {{cleanup_disc_space_folder}}cleanup-disc-space.sh {{size_percent_cleanup_disc_space}} && systemctl start system-maintenance-service-defrost.service'
|
ExecStart=/bin/sh -c '/bin/bash {{cleanup_disc_space_folder}}cleanup-disc-space.sh {{size_percent_cleanup_disc_space}} && systemctl start system-maintenance-service-defrost.service'
|
@ -4,5 +4,5 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze "{{ system_maintenance_services | join(' ') }}" --ignore "{{system_maintenance_cleanup_services| join(' ') }}" --timeout "{{system_maintenance_timeout_backup_services}}"'
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_cleanup_services| join(' ') }} --timeout "{{system_maintenance_timeout_backup_services}}"'
|
||||||
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bash {{backup_docker_to_local_cleanup_folder}}cleanup.sh {{backup_docker_to_local_cleanup_machine_id}} {{backup_docker_to_local_cleanup_trigger_directory}} && systemctl start system-maintenance-service-defrost.service'
|
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bash {{backup_docker_to_local_cleanup_folder}}cleanup.sh {{backup_docker_to_local_cleanup_machine_id}} {{backup_docker_to_local_cleanup_trigger_directory}} && systemctl start system-maintenance-service-defrost.service'
|
@ -4,5 +4,5 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze "{{ system_maintenance_services | join(' ') }}" --ignore "{{system_maintenance_cleanup_services| join(' ') }}" --timeout "{{system_maintenance_timeout_heal_docker}}"'
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_cleanup_services| join(' ') }} --timeout "{{system_maintenance_timeout_heal_docker}}"'
|
||||||
ExecStart=/bin/sh -c '/bin/python {{heal_docker}}heal-docker.py && systemctl start system-maintenance-service-defrost.service'
|
ExecStart=/bin/sh -c '/bin/python {{heal_docker}}heal-docker.py && systemctl start system-maintenance-service-defrost.service'
|
@ -51,9 +51,7 @@ def stop_timer(service):
|
|||||||
"""
|
"""
|
||||||
Stop and disable a systemd timer for a service if it exists.
|
Stop and disable a systemd timer for a service if it exists.
|
||||||
"""
|
"""
|
||||||
if service == "system-maintenance-service-defrost":
|
if service_file_exists(service, "timer"):
|
||||||
print(f"Ignore: {service}")
|
|
||||||
elif service_file_exists(service, "timer"):
|
|
||||||
timer_name = f"{service}.timer"
|
timer_name = f"{service}.timer"
|
||||||
subprocess.run(['systemctl', 'stop', timer_name])
|
subprocess.run(['systemctl', 'stop', timer_name])
|
||||||
subprocess.run(['systemctl', 'disable', timer_name])
|
subprocess.run(['systemctl', 'disable', timer_name])
|
||||||
@ -119,6 +117,12 @@ def main(services, ignored_services, action, timeout_sec):
|
|||||||
"""
|
"""
|
||||||
Main function to process the command-line arguments and perform actions.
|
Main function to process the command-line arguments and perform actions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Ignoring the current running service
|
||||||
|
running_service=f"system-maintenance-service-{action}"
|
||||||
|
if running_service not in ignored_services:
|
||||||
|
ignored_services.append(running_service)
|
||||||
|
|
||||||
filtered_services = filter_services(services, ignored_services)
|
filtered_services = filter_services(services, ignored_services)
|
||||||
print(f"Services to handle: {services}")
|
print(f"Services to handle: {services}")
|
||||||
print(f"Services to ignore: {ignored_services}")
|
print(f"Services to ignore: {ignored_services}")
|
||||||
|
@ -5,9 +5,14 @@
|
|||||||
dest: "{{path_system_maintenance_service_freezer_script}}"
|
dest: "{{path_system_maintenance_service_freezer_script}}"
|
||||||
when: run_once_system_maintenance_service_freeze is not defined
|
when: run_once_system_maintenance_service_freeze is not defined
|
||||||
|
|
||||||
- name: run the system_maintenance_service_freezer tasks once
|
- name: Configure system-maintenance-service for each action
|
||||||
set_fact:
|
loop:
|
||||||
run_once_system_maintenance_service_freeze: true
|
- 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"
|
||||||
when: run_once_system_maintenance_service_freeze is not defined
|
when: run_once_system_maintenance_service_freeze is not defined
|
||||||
|
|
||||||
- name: "restart system-maintenance-service.service"
|
- name: "restart system-maintenance-service.service"
|
||||||
@ -18,10 +23,6 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
when: maintenance_service_freeze_action_last is not defined or maintenance_service_freeze_action_last != system_maintenance_service_freeze_action
|
when: maintenance_service_freeze_action_last is not defined or maintenance_service_freeze_action_last != system_maintenance_service_freeze_action
|
||||||
|
|
||||||
- name: "set variable to prevent loading when action status didn't change"
|
|
||||||
set_fact:
|
|
||||||
maintenance_service_freeze_action_last: "{{system_maintenance_service_freeze_action}}"
|
|
||||||
|
|
||||||
- name: create system-maintenance-service-defrost.timer
|
- name: create system-maintenance-service-defrost.timer
|
||||||
template:
|
template:
|
||||||
src: system-maintenance-service-defrost.timer.j2
|
src: system-maintenance-service-defrost.timer.j2
|
||||||
@ -30,3 +31,14 @@
|
|||||||
changed_when: system_maintenance_service_defrost_timer.changed or activate_all_timers | bool
|
changed_when: system_maintenance_service_defrost_timer.changed or activate_all_timers | bool
|
||||||
notify: restart system-maintenance-service-defrost.timer
|
notify: restart system-maintenance-service-defrost.timer
|
||||||
when: run_once_system_maintenance_service_freeze is not defined
|
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}}"
|
||||||
|
@ -4,5 +4,5 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecPreStart=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} {{item}} "{{ system_maintenance_services + [item] | join(' ') }}" --ignore "{{item}}" --timeout "{{system_maintenance_timeout_defroster}}"'
|
ExecPreStart=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} {{item}} {{ system_maintenance_services | join(' ') }} --timeout "{{system_maintenance_timeout_defroster}}"'
|
||||||
ExecStart=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} {{item}} "{{ system_maintenance_services }}"'
|
ExecStart=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} {{item}} {{ system_maintenance_services | join(' ') }}'
|
@ -5,5 +5,5 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
{% if force_backup_before_update | bool %}ExecStartPre=/bin/sh -c 'systemctl start backup-docker-to-local.service'{% endif %}
|
{% if force_backup_before_update | bool %}ExecStartPre=/bin/sh -c 'systemctl start backup-docker-to-local.service'{% endif %}
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze "{{ system_maintenance_services | join(' ') }}" --ignore "{{system_maintenance_cleanup_services + ['update-docker'] | join(' ') }}" --timeout "{{system_maintenance_timeout_heal_docker}}"'
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_maintenance_service_freezer_script }} freeze {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_cleanup_services + ['update-docker'] | join(' ') }} --timeout "{{system_maintenance_timeout_heal_docker}}"'
|
||||||
ExecStart=/bin/sh -c '/usr/bin/python {{update_docker_script}} {{path_docker_compose_instances}} && systemctl start system-maintenance-service-defrost.service'
|
ExecStart=/bin/sh -c '/usr/bin/python {{update_docker_script}} {{path_docker_compose_instances}} && systemctl start system-maintenance-service-defrost.service'
|
Loading…
Reference in New Issue
Block a user