Implemented freezer for docker

This commit is contained in:
Kevin Veen-Birkenbach 2023-12-13 21:14:08 +01:00
parent 9ba58f82c1
commit b97018d84c
15 changed files with 46 additions and 9 deletions

8
destructor.yml Normal file
View File

@ -0,0 +1,8 @@
---
- name: call destructor method
hosts: all
become: true
roles:
- role: system-maintenance-service-freezer
vars:
system_maintenance_service_freeze_action: "defrost"

View File

@ -101,3 +101,5 @@
become: true become: true
roles: roles:
- driver-msi-keyboard-color - driver-msi-keyboard-color
- import_playbook: destructor.yml

View File

@ -79,6 +79,8 @@ system_maintenance_services:
- "heal-docker" - "heal-docker"
- "update-docker" - "update-docker"
system_maintenance_service_freeze_action: 'freeze' # Valid Values: freeze, defrost
# Routings # Routings
redirect_domain_mappings: redirect_domain_mappings:
- { source: "nextcloud.{{top_domain}}", target: "cloud.{{top_domain}}" } - { source: "nextcloud.{{top_domain}}", target: "cloud.{{top_domain}}" }

View File

@ -1,3 +1,4 @@
--- ---
dependencies: dependencies:
- role: cleanup-backups-service - role: cleanup-backups-service
- role: system-maintenance-service-freezer

View File

@ -3,3 +3,4 @@ dependencies:
- backups-provider - backups-provider
- systemd-notifier - systemd-notifier
- cleanup-failed-docker-backups - cleanup-failed-docker-backups
- system-maintenance-service-freezer

View File

@ -3,3 +3,4 @@ dependencies:
- systemd-notifier - systemd-notifier
- cleanup-backups-timer - cleanup-backups-timer
- cleanup-failed-docker-backups - cleanup-failed-docker-backups
- system-maintenance-service-freezer

View File

@ -1,3 +1,4 @@
dependencies: dependencies:
- python-pip - python-pip
- systemd-notifier - systemd-notifier
- system-maintenance-service-freezer

View File

@ -1,2 +1,3 @@
dependencies: dependencies:
- systemd-notifier - systemd-notifier
- system-maintenance-service-freezer

View File

@ -1,3 +1,4 @@
dependencies: dependencies:
- git - git
- systemd-notifier - systemd-notifier
- system-maintenance-service-freezer

View File

@ -0,0 +1,2 @@
dependencies:
- system-maintenance-service-freezer

View File

@ -1,9 +1,9 @@
- name: "restart system-maintenance-service-freeze.service" - name: "reload system-maintenance-service-freeze.service"
systemd: systemd:
name: system-maintenance-service-freeze.service name: system-maintenance-service-freeze.service
daemon_reload: yes daemon_reload: yes
- name: "restart system-maintenance-service-defrost.service" - name: "reload system-maintenance-service-defrost.service"
systemd: systemd:
name: system-maintenance-service-defrost.service name: system-maintenance-service-defrost.service
daemon_reload: yes daemon_reload: yes

View File

@ -3,6 +3,7 @@
copy: copy:
src: system-maintenance-service-freezer.py src: system-maintenance-service-freezer.py
dest: "{{path_system_maintenance_service_freezer_script}}" dest: "{{path_system_maintenance_service_freezer_script}}"
when: run_once_system_maintenance_service_freeze is not defined
- name: Configure system-maintenance-service for each action - name: Configure system-maintenance-service for each action
loop: loop:
@ -11,10 +12,22 @@
template: template:
src: system-maintenance-service-freezer.service.j2 src: system-maintenance-service-freezer.service.j2
dest: "/etc/systemd/system/system-maintenance-service-{{ item }}.service" dest: "/etc/systemd/system/system-maintenance-service-{{ item }}.service"
notify: "restart system-maintenance-service-{{ item }} service" notify: "reload system-maintenance-service-{{ item }} service"
when: run_once_systemd_freezer is not defined when: run_once_system_maintenance_service_freeze is not defined
- name: run the system_maintenance_service_freezer tasks once - name: run the system_maintenance_service_freezer tasks once
set_fact: set_fact:
run_once_systemd_freezer: true run_once_system_maintenance_service_freeze: true
when: run_once_systemd_freezer is not defined 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
state: restart
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
- name: "set variable to prevent loading when action status didn't change"
set_fact:
maintenance_service_freeze_action_last: "{{system_maintenance_service_freeze_action}}"

View File

@ -0,0 +1,2 @@
dependencies:
- system-maintenance-service-freezer

View File

@ -1,6 +1,6 @@
--- ---
- import_playbook: playbook-common.yml - import_playbook: constructor.yml
- name: servers host setup - name: servers host setup
hosts: servers hosts: servers
@ -241,3 +241,5 @@
roles: roles:
- role: nginx-www-redirect - role: nginx-www-redirect
when: nginx_www_redirect | bool when: nginx_www_redirect | bool
- import_playbook: destructor.yml