From 4b576a40f98f2f343e9be0e42a2815d6d6f20e97 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 15 Apr 2023 17:06:10 +0200 Subject: [PATCH] Implemented server tact --- group_vars/all | 10 ++++++++++ roles/docker-mailu/README.md | 2 +- roles/docker-mailu/vars/main.yml | 1 - roles/native-backups-cleanup/handlers/main.yml | 4 ++-- roles/native-backups-cleanup/tasks/main.yml | 6 +++--- .../backups-cleanup.timer.j2} | 3 +-- roles/native-btrfs-health-check/handlers/main.yml | 4 ++-- roles/native-btrfs-health-check/tasks/main.yml | 6 +++--- .../btrfs-health-check.timer.j2} | 2 +- .../handlers/main.yml | 2 +- .../tasks/main.yml | 6 +++--- .../docker-compose-restart-unhealthy.timer.j2} | 3 +-- roles/native-docker-health-check/handlers/main.yml | 4 ++-- roles/native-docker-health-check/tasks/main.yml | 6 +++--- .../docker-health-check.timer.j2} | 2 +- roles/native-docker-volume-backup/handlers/main.yml | 4 ++-- roles/native-docker-volume-backup/tasks/main.yml | 8 +++++--- .../templates/docker-volume-backup.timer.j2 | 3 +-- .../native-journalctl-health-check/handlers/main.yml | 6 ++++++ roles/native-journalctl-health-check/tasks/main.yml | 11 +++++++---- .../journalctl-health-check.timer.j2} | 2 +- roles/native-pull-primary-backups/handlers/main.yml | 4 ++-- roles/native-pull-primary-backups/tasks/main.yml | 2 +- .../templates/pull-remote-backups.timer.j2 | 3 +-- 24 files changed, 60 insertions(+), 44 deletions(-) create mode 100644 group_vars/all rename roles/native-backups-cleanup/{files/backups-cleanup.timer => templates/backups-cleanup.timer.j2} (71%) rename roles/native-btrfs-health-check/{files/btrfs-health-check.timer => templates/btrfs-health-check.timer.j2} (67%) rename roles/native-docker-compose-restart-unhealthy/{files/docker-compose-restart-unhealthy.timer => templates/docker-compose-restart-unhealthy.timer.j2} (64%) rename roles/native-docker-health-check/{files/docker-health-check.timer => templates/docker-health-check.timer.j2} (67%) rename roles/native-journalctl-health-check/{files/journalctl-health-check.timer => templates/journalctl-health-check.timer.j2} (66%) diff --git a/group_vars/all b/group_vars/all new file mode 100644 index 00000000..d8f9875f --- /dev/null +++ b/group_vars/all @@ -0,0 +1,10 @@ +# Server Tact Variables +# @see https://man.archlinux.org/man/systemd.time.7 + +on_calendar_btrfs_health_check: "*-*-* 00:00:00" +on_calendar_journalctl_health_check: "*-*-* 00:00:00" +on_calendar_docker_health_check: "*-*-* 09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00,01,02:00:00" +on_calendar_backups_cleanup: "*-*-* 06,12,18,00:30:00" +on_calendar_docker_volume_backup: "*-*-* 03:30:00" +on_calendar_docker_compose_restart_unhealthy: "*-*-* 09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00,01:30:00" +on_calendar_pull_primary_backups: "*-*-* 21:30:00" \ No newline at end of file diff --git a/roles/docker-mailu/README.md b/roles/docker-mailu/README.md index 3a22c6ea..575f5c34 100644 --- a/roles/docker-mailu/README.md +++ b/roles/docker-mailu/README.md @@ -60,7 +60,7 @@ How to manage users is described here: https://mailu.io/master/cli.html ### database access To access the database execute ```bash - docker exec -it nextcloud_database_1 mysql -u nextcloud -D nextcloud -p + docker exec -it mailu-database-1 mysql -u root -D mailu -p ``` ### mailu_front_1 diff --git a/roles/docker-mailu/vars/main.yml b/roles/docker-mailu/vars/main.yml index 0d845c4b..1989bbe9 100644 --- a/roles/docker-mailu/vars/main.yml +++ b/roles/docker-mailu/vars/main.yml @@ -1,2 +1 @@ mailu_front_container_name: "mailu-front-1" -mailu_version: "1.9" diff --git a/roles/native-backups-cleanup/handlers/main.yml b/roles/native-backups-cleanup/handlers/main.yml index aa7db473..ad2bb49b 100644 --- a/roles/native-backups-cleanup/handlers/main.yml +++ b/roles/native-backups-cleanup/handlers/main.yml @@ -1,7 +1,7 @@ -- name: "restart backups-cleanup.service" +- name: "reload backups-cleanup.service" systemd: name: backups-cleanup.service - state: restarted + state: reloaded enabled: yes daemon_reload: yes - name: "restart backups-cleanup.timer" diff --git a/roles/native-backups-cleanup/tasks/main.yml b/roles/native-backups-cleanup/tasks/main.yml index 7239b899..6a3f2f86 100644 --- a/roles/native-backups-cleanup/tasks/main.yml +++ b/roles/native-backups-cleanup/tasks/main.yml @@ -13,10 +13,10 @@ - name: create backups-cleanup.service template: src=backups-cleanup.service.j2 dest=/etc/systemd/system/backups-cleanup.service - notify: restart backups-cleanup.service + notify: reload backups-cleanup.service - name: create backups-cleanup.timer - copy: - src: backups-cleanup.timer + template: + src: backups-cleanup.timer.j2 dest: "/etc/systemd/system/backups-cleanup.timer" notify: restart backups-cleanup.timer diff --git a/roles/native-backups-cleanup/files/backups-cleanup.timer b/roles/native-backups-cleanup/templates/backups-cleanup.timer.j2 similarity index 71% rename from roles/native-backups-cleanup/files/backups-cleanup.timer rename to roles/native-backups-cleanup/templates/backups-cleanup.timer.j2 index 141153da..ffbe6f7f 100644 --- a/roles/native-backups-cleanup/files/backups-cleanup.timer +++ b/roles/native-backups-cleanup/templates/backups-cleanup.timer.j2 @@ -3,8 +3,7 @@ Description=starts backups-cleanup.service [Timer] OnBootSec=1min -OnUnitActiveSec=3h -RandomizedDelaySec=1h +OnCalendar={{on_calendar_backups_cleanup}} [Install] WantedBy=timers.target diff --git a/roles/native-btrfs-health-check/handlers/main.yml b/roles/native-btrfs-health-check/handlers/main.yml index a6104905..3b37eed7 100644 --- a/roles/native-btrfs-health-check/handlers/main.yml +++ b/roles/native-btrfs-health-check/handlers/main.yml @@ -1,7 +1,7 @@ -- name: "restart btrfs-health-check.service" +- name: "reload btrfs-health-check.service" systemd: name: btrfs-health-check.service - state: restarted + state: reloaded enabled: yes daemon_reload: yes - name: "restart btrfs-health-check.timer" diff --git a/roles/native-btrfs-health-check/tasks/main.yml b/roles/native-btrfs-health-check/tasks/main.yml index 5942d9de..4b1efa88 100644 --- a/roles/native-btrfs-health-check/tasks/main.yml +++ b/roles/native-btrfs-health-check/tasks/main.yml @@ -13,10 +13,10 @@ template: src: btrfs-health-check.service.j2 dest: /etc/systemd/system/btrfs-health-check.service - notify: restart btrfs-health-check.service + notify: reload btrfs-health-check.service - name: create btrfs-health-check.timer - copy: - src: btrfs-health-check.timer + template: + src: btrfs-health-check.timer.j2 dest: "/etc/systemd/system/btrfs-health-check.timer" notify: restart btrfs-health-check.timer diff --git a/roles/native-btrfs-health-check/files/btrfs-health-check.timer b/roles/native-btrfs-health-check/templates/btrfs-health-check.timer.j2 similarity index 67% rename from roles/native-btrfs-health-check/files/btrfs-health-check.timer rename to roles/native-btrfs-health-check/templates/btrfs-health-check.timer.j2 index 9f116f74..81ea384c 100644 --- a/roles/native-btrfs-health-check/files/btrfs-health-check.timer +++ b/roles/native-btrfs-health-check/templates/btrfs-health-check.timer.j2 @@ -2,7 +2,7 @@ Description=starts btrfs-health-check.service [Timer] -OnCalendar=12:00 +OnCalendar={{on_calendar_btrfs_health_check}} [Install] WantedBy=timers.target diff --git a/roles/native-docker-compose-restart-unhealthy/handlers/main.yml b/roles/native-docker-compose-restart-unhealthy/handlers/main.yml index a296836f..d16bba4c 100644 --- a/roles/native-docker-compose-restart-unhealthy/handlers/main.yml +++ b/roles/native-docker-compose-restart-unhealthy/handlers/main.yml @@ -1,4 +1,4 @@ -- name: "reloaded docker-compose-restart-unhealthy.service" +- name: "reload docker-compose-restart-unhealthy.service" systemd: name: docker-compose-restart-unhealthy.service state: reloaded diff --git a/roles/native-docker-compose-restart-unhealthy/tasks/main.yml b/roles/native-docker-compose-restart-unhealthy/tasks/main.yml index 181f30f8..b3d9e773 100644 --- a/roles/native-docker-compose-restart-unhealthy/tasks/main.yml +++ b/roles/native-docker-compose-restart-unhealthy/tasks/main.yml @@ -13,10 +13,10 @@ template: src: docker-compose-restart-unhealthy.service.j2 dest: /etc/systemd/system/docker-compose-restart-unhealthy.service - notify: reloaded docker-compose-restart-unhealthy.service + notify: reload docker-compose-restart-unhealthy.service - name: create docker-compose-restart-unhealthy.timer - copy: - src: docker-compose-restart-unhealthy.timer + template: + src: docker-compose-restart-unhealthy.timer.j2 dest: "/etc/systemd/system/docker-compose-restart-unhealthy.timer" notify: restart docker-compose-restart-unhealthy.timer \ No newline at end of file diff --git a/roles/native-docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.timer b/roles/native-docker-compose-restart-unhealthy/templates/docker-compose-restart-unhealthy.timer.j2 similarity index 64% rename from roles/native-docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.timer rename to roles/native-docker-compose-restart-unhealthy/templates/docker-compose-restart-unhealthy.timer.j2 index 6d8ab9ea..87c6146f 100644 --- a/roles/native-docker-compose-restart-unhealthy/files/docker-compose-restart-unhealthy.timer +++ b/roles/native-docker-compose-restart-unhealthy/templates/docker-compose-restart-unhealthy.timer.j2 @@ -2,8 +2,7 @@ Description=starts docker-compose-restart-unhealthy.service [Timer] -OnBootSec=1min -OnUnitActiveSec=1h +OnCalendar={{on_calendar_docker_compose_restart_unhealthy}} [Install] WantedBy=timers.target diff --git a/roles/native-docker-health-check/handlers/main.yml b/roles/native-docker-health-check/handlers/main.yml index 8aec3318..cdaa75db 100644 --- a/roles/native-docker-health-check/handlers/main.yml +++ b/roles/native-docker-health-check/handlers/main.yml @@ -1,7 +1,7 @@ -- name: "restart docker-health-check.service" +- name: "reload docker-health-check.service" systemd: name: docker-health-check.service - state: restarted + state: reloaded enabled: yes daemon_reload: yes - name: "restart docker-health-check.timer" diff --git a/roles/native-docker-health-check/tasks/main.yml b/roles/native-docker-health-check/tasks/main.yml index d11afdc2..aeecbd72 100644 --- a/roles/native-docker-health-check/tasks/main.yml +++ b/roles/native-docker-health-check/tasks/main.yml @@ -11,10 +11,10 @@ - name: create docker-health-check.service template: src=docker-health-check.service.j2 dest=/etc/systemd/system/docker-health-check.service - notify: restart docker-health-check.service + notify: reload docker-health-check.service - name: create docker-health-check.timer - copy: - src: docker-health-check.timer + template: + src: docker-health-check.timer.j2 dest: "/etc/systemd/system/docker-health-check.timer" notify: restart docker-health-check.timer diff --git a/roles/native-docker-health-check/files/docker-health-check.timer b/roles/native-docker-health-check/templates/docker-health-check.timer.j2 similarity index 67% rename from roles/native-docker-health-check/files/docker-health-check.timer rename to roles/native-docker-health-check/templates/docker-health-check.timer.j2 index e3bb3bfb..8e019b8d 100644 --- a/roles/native-docker-health-check/files/docker-health-check.timer +++ b/roles/native-docker-health-check/templates/docker-health-check.timer.j2 @@ -2,7 +2,7 @@ Description=starts docker-health-check.service [Timer] -OnCalendar=10:00 +OnCalendar={{on_calendar_docker_health_check}} [Install] WantedBy=timers.target diff --git a/roles/native-docker-volume-backup/handlers/main.yml b/roles/native-docker-volume-backup/handlers/main.yml index c366d08d..1cb7373e 100644 --- a/roles/native-docker-volume-backup/handlers/main.yml +++ b/roles/native-docker-volume-backup/handlers/main.yml @@ -1,7 +1,7 @@ -- name: "restart docker-volume-backup service" +- name: "reload docker-volume-backup service" systemd: name: docker-volume-backup.service - state: restarted + state: reloaded enabled: yes daemon_reload: yes - name: "restart docker-volume-backup timer" diff --git a/roles/native-docker-volume-backup/tasks/main.yml b/roles/native-docker-volume-backup/tasks/main.yml index 25f887d1..d63ae3e2 100644 --- a/roles/native-docker-volume-backup/tasks/main.yml +++ b/roles/native-docker-volume-backup/tasks/main.yml @@ -8,9 +8,11 @@ dest: "{{docker_volume_backup_folder}}" update: yes -- name: configure docker-volume-backup.service.tpl - template: src=docker-volume-backup.service.j2 dest=/etc/systemd/system/docker-volume-backup.service - notify: restart docker-volume-backup service +- name: configure docker-volume-backup.service + template: + src: docker-volume-backup.service.j2 + dest: /etc/systemd/system/docker-volume-backup.service + notify: reload docker-volume-backup service - name: configure docker-volume-backup.timer.tpl template: src=docker-volume-backup.timer.j2 dest=/etc/systemd/system/docker-volume-backup.timer diff --git a/roles/native-docker-volume-backup/templates/docker-volume-backup.timer.j2 b/roles/native-docker-volume-backup/templates/docker-volume-backup.timer.j2 index 5d0451bc..5c576a4c 100644 --- a/roles/native-docker-volume-backup/templates/docker-volume-backup.timer.j2 +++ b/roles/native-docker-volume-backup/templates/docker-volume-backup.timer.j2 @@ -2,8 +2,7 @@ Description=backups the docker volumes [Timer] -OnCalendar=3:00 -RandomizedDelaySec=1h +OnCalendar={{on_calendar_docker_volume_backup}} [Install] WantedBy=timers.target diff --git a/roles/native-journalctl-health-check/handlers/main.yml b/roles/native-journalctl-health-check/handlers/main.yml index c934f249..2b1afb60 100644 --- a/roles/native-journalctl-health-check/handlers/main.yml +++ b/roles/native-journalctl-health-check/handlers/main.yml @@ -1,3 +1,9 @@ +- name: "reload journalctl-health-check.service" + systemd: + name: journalctl-health-check.service + state: reloaded + enabled: yes + daemon_reload: yes - name: "restart journalctl-health-check.timer" systemd: name: journalctl-health-check.timer diff --git a/roles/native-journalctl-health-check/tasks/main.yml b/roles/native-journalctl-health-check/tasks/main.yml index 9b151914..ed68508c 100644 --- a/roles/native-journalctl-health-check/tasks/main.yml +++ b/roles/native-journalctl-health-check/tasks/main.yml @@ -10,10 +10,13 @@ dest: "{{journalctl_health_check_folder}}journalctl-health-check.sh" - name: create journalctl-health-check.service - template: src=journalctl-health-check.service.j2 dest=/etc/systemd/system/journalctl-health-check.service + template: + src: journalctl-health-check.service.j2 + dest: /etc/systemd/system/journalctl-health-check.service + notify: reload journalctl-health-check.service - name: create journalctl-health-check.timer - copy: - src: journalctl-health-check.timer - dest: "/etc/systemd/system/journalctl-health-check.timer" + template: + src: journalctl-health-check.timer.j2 + dest: /etc/systemd/system/journalctl-health-check.timer notify: restart journalctl-health-check.timer diff --git a/roles/native-journalctl-health-check/files/journalctl-health-check.timer b/roles/native-journalctl-health-check/templates/journalctl-health-check.timer.j2 similarity index 66% rename from roles/native-journalctl-health-check/files/journalctl-health-check.timer rename to roles/native-journalctl-health-check/templates/journalctl-health-check.timer.j2 index ec27e6c7..13c02e73 100644 --- a/roles/native-journalctl-health-check/files/journalctl-health-check.timer +++ b/roles/native-journalctl-health-check/templates/journalctl-health-check.timer.j2 @@ -2,7 +2,7 @@ Description=starts journalctl-health-check.service [Timer] -OnCalendar=00:00 +OnCalendar={{on_calendar_journalctl_health_check}} [Install] WantedBy=timers.target diff --git a/roles/native-pull-primary-backups/handlers/main.yml b/roles/native-pull-primary-backups/handlers/main.yml index fc72e9e3..40b514e7 100644 --- a/roles/native-pull-primary-backups/handlers/main.yml +++ b/roles/native-pull-primary-backups/handlers/main.yml @@ -1,7 +1,7 @@ -- name: "restart pull-remote-backups service" +- name: "reload pull-remote-backups service" systemd: name: pull-remote-backups.service - state: restarted + state: reloaded enabled: yes daemon_reload: yes - name: "restart pull-remote-backups timer" diff --git a/roles/native-pull-primary-backups/tasks/main.yml b/roles/native-pull-primary-backups/tasks/main.yml index 68d587ef..09d54239 100644 --- a/roles/native-pull-primary-backups/tasks/main.yml +++ b/roles/native-pull-primary-backups/tasks/main.yml @@ -12,7 +12,7 @@ - name: create pull-remote-backups.service template: src=pull-remote-backups.service.j2 dest=/etc/systemd/system/pull-remote-backups.service - notify: restart pull-remote-backups service + notify: reload pull-remote-backups service - name: create pull-remote-backups.timer template: src=pull-remote-backups.timer.j2 dest=/etc/systemd/system/pull-remote-backups.timer diff --git a/roles/native-pull-primary-backups/templates/pull-remote-backups.timer.j2 b/roles/native-pull-primary-backups/templates/pull-remote-backups.timer.j2 index 254c7c80..6f4b9986 100644 --- a/roles/native-pull-primary-backups/templates/pull-remote-backups.timer.j2 +++ b/roles/native-pull-primary-backups/templates/pull-remote-backups.timer.j2 @@ -2,8 +2,7 @@ Description=starts pull remote backup timer [Timer] -OnCalendar=22:00 -RandomizedDelaySec=1h +OnCalendar={{on_calendar_pull_primary_backups}} [Install] WantedBy=timers.target