Implemented freezer for docker

This commit is contained in:
Kevin Veen-Birkenbach 2023-12-13 21:14:08 +01:00
parent 8c89d08980
commit 1ad6c6110a
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
roles:
- driver-msi-keyboard-color
- import_playbook: destructor.yml

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,4 @@
dependencies:
- git
- 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:
name: system-maintenance-service-freeze.service
daemon_reload: yes
- name: "restart system-maintenance-service-defrost.service"
- name: "reload system-maintenance-service-defrost.service"
systemd:
name: system-maintenance-service-defrost.service
daemon_reload: yes

View File

@ -3,6 +3,7 @@
copy:
src: system-maintenance-service-freezer.py
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
loop:
@ -11,10 +12,22 @@
template:
src: system-maintenance-service-freezer.service.j2
dest: "/etc/systemd/system/system-maintenance-service-{{ item }}.service"
notify: "restart system-maintenance-service-{{ item }} service"
when: run_once_systemd_freezer is not defined
notify: "reload system-maintenance-service-{{ item }} service"
when: run_once_system_maintenance_service_freeze is not defined
- name: run the system_maintenance_service_freezer tasks once
set_fact:
run_once_systemd_freezer: true
when: run_once_systemd_freezer is not defined
run_once_system_maintenance_service_freeze: true
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
hosts: servers
@ -241,3 +241,5 @@
roles:
- role: nginx-www-redirect
when: nginx_www_redirect | bool
- import_playbook: destructor.yml