From 298b1d106e8e168d11f0a570525480be1d9876d8 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 16 Nov 2023 19:43:54 +0100 Subject: [PATCH] Implemented -e "activate_all_timers=true" --- .../templates/backup-data-to-usb.service.j2 | 2 +- roles/backup-docker-to-local/tasks/main.yml | 2 ++ roles/backup-remote-to-local/tasks/main.yml | 2 ++ roles/certbot-nginx/tasks/main.yml | 2 ++ .../{backups-cleanup.py => cleanup-backups.py} | 0 roles/cleanup-backups-service/handlers/main.yml | 4 ++-- roles/cleanup-backups-service/tasks/main.yml | 14 +++++++------- ...eanup.service.j2 => cleanup-backups.service.j2} | 2 +- roles/cleanup-backups-service/vars/main.yml | 2 +- roles/cleanup-backups-timer/handlers/main.yml | 4 ++-- roles/cleanup-backups-timer/tasks/main.yml | 10 ++++++---- ...s-cleanup.timer.j2 => cleanup-backups.timer.j2} | 2 +- roles/cleanup-disc-space/tasks/main.yml | 2 ++ .../templates/cleanup-disc-space.sh.j2 | 2 +- roles/docker-mailu/tasks/main.yml | 2 ++ roles/heal-docker/tasks/main.yml | 2 ++ roles/health-btrfs/tasks/main.yml | 2 ++ roles/health-disc-space/tasks/main.yml | 2 ++ roles/health-docker/tasks/main.yml | 2 ++ roles/health-journalctl/tasks/main.yml | 2 ++ 20 files changed, 42 insertions(+), 20 deletions(-) rename roles/cleanup-backups-service/files/{backups-cleanup.py => cleanup-backups.py} (100%) rename roles/cleanup-backups-service/templates/{backups-cleanup.service.j2 => cleanup-backups.service.j2} (54%) rename roles/cleanup-backups-timer/templates/{backups-cleanup.timer.j2 => cleanup-backups.timer.j2} (78%) diff --git a/roles/backup-data-to-usb/templates/backup-data-to-usb.service.j2 b/roles/backup-data-to-usb/templates/backup-data-to-usb.service.j2 index d5398db3..2e6cdee8 100644 --- a/roles/backup-data-to-usb/templates/backup-data-to-usb.service.j2 +++ b/roles/backup-data-to-usb/templates/backup-data-to-usb.service.j2 @@ -5,7 +5,7 @@ OnFailure=systemd-notifier@%n.service [Service] ExecStart=/bin/python {{ backup_to_usb_script_path }} {{backup_to_usb_source}} {{backup_to_usb_destination}} -ExecStartPost=/bin/systemctl start backups-cleanup.service +ExecStartPost=/bin/systemctl start cleanup-backups.service [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/roles/backup-docker-to-local/tasks/main.yml b/roles/backup-docker-to-local/tasks/main.yml index 255cb876..f6e1cbea 100644 --- a/roles/backup-docker-to-local/tasks/main.yml +++ b/roles/backup-docker-to-local/tasks/main.yml @@ -26,6 +26,8 @@ - name: configure backup-docker-to-local.timer.tpl template: src=backup-docker-to-local.timer.j2 dest=/etc/systemd/system/backup-docker-to-local.timer + register: backup_docker_to_local_timer + changed_when: backup_docker_to_local_timer.changed or activate_all_timers | default(false) | bool notify: restart backup-docker-to-local.timer - name: create {{docker_volume_backup_folder}}databases.csv diff --git a/roles/backup-remote-to-local/tasks/main.yml b/roles/backup-remote-to-local/tasks/main.yml index da272c11..b2ef141d 100644 --- a/roles/backup-remote-to-local/tasks/main.yml +++ b/roles/backup-remote-to-local/tasks/main.yml @@ -16,6 +16,8 @@ - name: create backup-remote-to-local.timer template: src=backup-remote-to-local.timer.j2 dest=/etc/systemd/system/backup-remote-to-local.timer + register: backup_remote_to_local_timer + changed_when: backup_remote_to_local_timer.changed or activate_all_timers | default(false) | bool notify: restart backup-remote-to-local timer - name: create backup-remote-to-local.sh diff --git a/roles/certbot-nginx/tasks/main.yml b/roles/certbot-nginx/tasks/main.yml index d0ed6270..e6b63603 100644 --- a/roles/certbot-nginx/tasks/main.yml +++ b/roles/certbot-nginx/tasks/main.yml @@ -13,4 +13,6 @@ template: src: certbot.timer.j2 dest: /etc/systemd/system/certbot.timer + register: certbot_timer + changed_when: certbot_timer.changed or activate_all_timers | default(false) | bool notify: restart certbot timer diff --git a/roles/cleanup-backups-service/files/backups-cleanup.py b/roles/cleanup-backups-service/files/cleanup-backups.py similarity index 100% rename from roles/cleanup-backups-service/files/backups-cleanup.py rename to roles/cleanup-backups-service/files/cleanup-backups.py diff --git a/roles/cleanup-backups-service/handlers/main.yml b/roles/cleanup-backups-service/handlers/main.yml index 43cba994..7e6ceb09 100644 --- a/roles/cleanup-backups-service/handlers/main.yml +++ b/roles/cleanup-backups-service/handlers/main.yml @@ -1,6 +1,6 @@ -- name: "reload backups-cleanup.service" +- name: "reload cleanup-backups.service" systemd: - name: backups-cleanup.service + name: cleanup-backups.service state: reloaded enabled: yes daemon_reload: yes diff --git a/roles/cleanup-backups-service/tasks/main.yml b/roles/cleanup-backups-service/tasks/main.yml index e26934cd..749614cb 100644 --- a/roles/cleanup-backups-service/tasks/main.yml +++ b/roles/cleanup-backups-service/tasks/main.yml @@ -11,13 +11,13 @@ state: directory mode: 0755 -- name: create backups-cleanup.py +- name: create cleanup-backups.py copy: - src: "backups-cleanup.py" - dest: "{{docker_backups_cleanup}}backups-cleanup.py" + src: "cleanup-backups.py" + dest: "{{docker_backups_cleanup}}cleanup-backups.py" -- name: create backups-cleanup.service +- name: create cleanup-backups.service template: - src: "backups-cleanup.service.j2" - dest: "/etc/systemd/system/backups-cleanup.service" - notify: reload backups-cleanup.service + src: "cleanup-backups.service.j2" + dest: "/etc/systemd/system/cleanup-backups.service" + notify: reload cleanup-backups.service diff --git a/roles/cleanup-backups-service/templates/backups-cleanup.service.j2 b/roles/cleanup-backups-service/templates/cleanup-backups.service.j2 similarity index 54% rename from roles/cleanup-backups-service/templates/backups-cleanup.service.j2 rename to roles/cleanup-backups-service/templates/cleanup-backups.service.j2 index 96f7cc9b..6126e6fe 100644 --- a/roles/cleanup-backups-service/templates/backups-cleanup.service.j2 +++ b/roles/cleanup-backups-service/templates/cleanup-backups.service.j2 @@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service [Service] Type=oneshot -ExecStart=/usr/bin/python {{docker_backups_cleanup}}backups-cleanup.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} +ExecStart=/usr/bin/python {{docker_backups_cleanup}}cleanup-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} diff --git a/roles/cleanup-backups-service/vars/main.yml b/roles/cleanup-backups-service/vars/main.yml index 2902c496..0ae8bf12 100644 --- a/roles/cleanup-backups-service/vars/main.yml +++ b/roles/cleanup-backups-service/vars/main.yml @@ -1 +1 @@ -docker_backups_cleanup: "{{path_administrator_scripts}}backups-cleanup/" \ No newline at end of file +docker_backups_cleanup: "{{path_administrator_scripts}}cleanup-backups/" \ No newline at end of file diff --git a/roles/cleanup-backups-timer/handlers/main.yml b/roles/cleanup-backups-timer/handlers/main.yml index 2338bed4..0913c641 100644 --- a/roles/cleanup-backups-timer/handlers/main.yml +++ b/roles/cleanup-backups-timer/handlers/main.yml @@ -1,6 +1,6 @@ -- name: "restart backups-cleanup.timer" +- name: "restart cleanup-backups.timer" systemd: - name: backups-cleanup.timer + name: cleanup-backups.timer state: restarted enabled: yes daemon_reload: yes diff --git a/roles/cleanup-backups-timer/tasks/main.yml b/roles/cleanup-backups-timer/tasks/main.yml index 47cae32f..6d5a1e01 100644 --- a/roles/cleanup-backups-timer/tasks/main.yml +++ b/roles/cleanup-backups-timer/tasks/main.yml @@ -1,5 +1,7 @@ -- name: create backups-cleanup.timer +- name: create cleanup-backups.timer template: - src: "backups-cleanup.timer.j2" - dest: "/etc/systemd/system/backups-cleanup.timer" - notify: restart backups-cleanup.timer + src: "cleanup-backups.timer.j2" + dest: "/etc/systemd/system/cleanup-backups.timer" + register: cleanup_backups_timer + changed_when: cleanup_backups_timer.changed or activate_all_timers | default(false) | bool + notify: restart cleanup-backups.timer diff --git a/roles/cleanup-backups-timer/templates/backups-cleanup.timer.j2 b/roles/cleanup-backups-timer/templates/cleanup-backups.timer.j2 similarity index 78% rename from roles/cleanup-backups-timer/templates/backups-cleanup.timer.j2 rename to roles/cleanup-backups-timer/templates/cleanup-backups.timer.j2 index 3ec81479..e3ef8fcf 100644 --- a/roles/cleanup-backups-timer/templates/backups-cleanup.timer.j2 +++ b/roles/cleanup-backups-timer/templates/cleanup-backups.timer.j2 @@ -1,5 +1,5 @@ [Unit] -Description=starts backups-cleanup.service +Description=starts cleanup-backups.service [Timer] OnCalendar={{on_calendar_backups_cleanup}} diff --git a/roles/cleanup-disc-space/tasks/main.yml b/roles/cleanup-disc-space/tasks/main.yml index 1b0e198d..9a26c558 100644 --- a/roles/cleanup-disc-space/tasks/main.yml +++ b/roles/cleanup-disc-space/tasks/main.yml @@ -19,4 +19,6 @@ template: src: cleanup-disc-space.timer.j2 dest: /etc/systemd/system/cleanup-disc-space.timer + register: cleanup_disc_space_timer + changed_when: cleanup_disc_space_timer.changed or activate_all_timers | default(false) | bool notify: restart cleanup-disc-space.timer \ No newline at end of file diff --git a/roles/cleanup-disc-space/templates/cleanup-disc-space.sh.j2 b/roles/cleanup-disc-space/templates/cleanup-disc-space.sh.j2 index 3268c612..319828ff 100644 --- a/roles/cleanup-disc-space/templates/cleanup-disc-space.sh.j2 +++ b/roles/cleanup-disc-space/templates/cleanup-disc-space.sh.j2 @@ -25,7 +25,7 @@ if [ "$disc_use_percent_number" -gt "$minimum_percent_free_disc_space" ] || [ "$ {% if backups_folder_path is defined and size_percent_maximum_backup is defined %} echo "cleaning up backups" && - python {{path_administrator_scripts}}backups-cleanup/backups-cleanup.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} || exit 2 + python {{path_administrator_scripts}}cleanup-backups/cleanup-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}} || exit 2 {% endif %} if pacman -Qs $package > /dev/null ; then diff --git a/roles/docker-mailu/tasks/main.yml b/roles/docker-mailu/tasks/main.yml index 0a983e7d..6d72f031 100644 --- a/roles/docker-mailu/tasks/main.yml +++ b/roles/docker-mailu/tasks/main.yml @@ -60,4 +60,6 @@ template: src: "deploy-letsencrypt-mailu.timer.j2" dest: "/etc/systemd/system/deploy-letsencrypt-mailu.timer" + register: deploy_letsencrypt_mailu_timer + changed_when: deploy_letsencrypt_mailu_timer.changed or activate_all_timers | default(false) | bool notify: restart deploy-letsencrypt-mailu.timer \ No newline at end of file diff --git a/roles/heal-docker/tasks/main.yml b/roles/heal-docker/tasks/main.yml index 5dd14c23..c6899d02 100644 --- a/roles/heal-docker/tasks/main.yml +++ b/roles/heal-docker/tasks/main.yml @@ -19,4 +19,6 @@ template: src: heal-docker.timer.j2 dest: "/etc/systemd/system/heal-docker.timer" + register: heal_docker_timer + changed_when: heal_docker_timer.changed or activate_all_timers | default(false) | bool notify: restart heal-docker.timer \ No newline at end of file diff --git a/roles/health-btrfs/tasks/main.yml b/roles/health-btrfs/tasks/main.yml index 9b7dfc90..229869b9 100644 --- a/roles/health-btrfs/tasks/main.yml +++ b/roles/health-btrfs/tasks/main.yml @@ -19,4 +19,6 @@ template: src: health-btrfs.timer.j2 dest: "/etc/systemd/system/health-btrfs.timer" + register: health_btrs_timer + changed_when: health_btrs_timer.changed or activate_all_timers | default(false) | bool notify: restart health-btrfs.timer diff --git a/roles/health-disc-space/tasks/main.yml b/roles/health-disc-space/tasks/main.yml index ef05b4d1..ddab22e1 100644 --- a/roles/health-disc-space/tasks/main.yml +++ b/roles/health-disc-space/tasks/main.yml @@ -19,4 +19,6 @@ template: src: health-disc-space.timer.j2 dest: /etc/systemd/system/health-disc-space.timer + register: health_disc_space_timer + changed_when: health_disc_space_timer.changed or activate_all_timers | default(false) | bool notify: restart health-disc-space.timer diff --git a/roles/health-docker/tasks/main.yml b/roles/health-docker/tasks/main.yml index 102ba4a4..492ed0a6 100644 --- a/roles/health-docker/tasks/main.yml +++ b/roles/health-docker/tasks/main.yml @@ -17,4 +17,6 @@ template: src: health-docker.timer.j2 dest: "/etc/systemd/system/health-docker.timer" + register: health_docker_timer + changed_when: health_docker_timer.changed or activate_all_timers | default(false) | bool notify: restart health-docker.timer diff --git a/roles/health-journalctl/tasks/main.yml b/roles/health-journalctl/tasks/main.yml index 987739c9..a8f21ae7 100644 --- a/roles/health-journalctl/tasks/main.yml +++ b/roles/health-journalctl/tasks/main.yml @@ -19,4 +19,6 @@ template: src: health-journalctl.timer.j2 dest: /etc/systemd/system/health-journalctl.timer + register: health_journalctl_timer + changed_when: health_journalctl_timer.changed or activate_all_timers | default(false) | bool notify: restart health-journalctl.timer