optimized variable names

This commit is contained in:
Kevin Veen-Birkenbach 2023-11-17 12:35:39 +01:00
parent 6bc6f52f5c
commit dfaa449989
47 changed files with 87 additions and 87 deletions

View File

@ -4,17 +4,17 @@
randomized_delay_sec: "15min"
on_calendar_btrfs_health_check: "*-*-* 00:00:00"
on_calendar_journalctl_health_check: "*-*-* 00:00:00"
on_calendar_disc_space_check: "*-*-* 06,12,18,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_nginx_health_check: "*-*-* 09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00,01,02:15:00"
on_calendar_health_btrfs: "*-*-* 00:00:00"
on_calendar_health_journalctl: "*-*-* 00:00:00"
on_calendar_health_disc_space: "*-*-* 06,12,18,00:00:00"
on_calendar_health_docker: "*-*-* 09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00,01,02:00:00"
on_calendar_health_nginx: "*-*-* 09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00,01,02:15:00"
on_calendar_backups_cleanup: "*-*-* 06,12,18,00:30:00"
on_calendar_free_disc_space: "*-*-* 07,13,19,01: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"
on_calendar_cleanup_backups: "*-*-* 06,12,18,00:30:00"
on_calendar_cleanup_disc_space: "*-*-* 07,13,19,01:30:00"
on_calendar_backup_docker_to_local: "*-*-* 03:30:00"
on_calendar_backup_remote_to_local: "*-*-* 21:30:00"
on_calendar_heal_docker: "*-*-* 09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00,01:30:00"
on_calendar_renew_lets_encrypt_certificates: "*-*-* 12,00:30:00"
on_calendar_deploy_mailu_certificates: "*-*-* 13,01:30:00"
on_calendar_msi_keyboard_color: "*-*-* *:*:00"
@ -22,7 +22,7 @@ on_calendar_msi_keyboard_color: "*-*-* *:*:00"
# Space Variables
size_percent_maximum_backup: 75
size_percent_disc_space_warning: 85
size_percent_free_disc_space: 90
size_percent_cleanup_disc_space: 90
# Path Variables
path_administrator_home: "/home/administrator/"

View File

@ -8,7 +8,7 @@
- name: pull backup-docker-to-local.git
git:
repo: "https://github.com/kevinveenbirkenbach/backup-docker-to-local.git"
dest: "{{docker_volume_backup_folder}}"
dest: "{{backup_docker_to_local_folder}}"
update: yes
register: git_result
ignore_errors: true
@ -30,9 +30,9 @@
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
- name: create {{backup_docker_to_local_folder}}databases.csv
copy:
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{docker_volume_backup_folder}}databases.csv"
dest: "{{docker_volume_backup_folder}}databases.csv"
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{backup_docker_to_local_folder}}databases.csv"
dest: "{{backup_docker_to_local_folder}}databases.csv"
owner: root
group: root

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service cleanup-failed-docker-backups.service
[Service]
Type=oneshot
ExecStart=/usr/bin/python {{docker_volume_backup_folder}}backup-docker-to-local.py
ExecStart=/usr/bin/python {{backup_docker_to_local_folder}}backup-docker-to-local.py

View File

@ -2,7 +2,7 @@
Description=backups the docker volumes
[Timer]
OnCalendar={{on_calendar_docker_volume_backup}}
OnCalendar={{on_calendar_backup_docker_to_local}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=false

View File

@ -1 +1 @@
docker_volume_backup_folder: "{{path_administrator_scripts}}backup-docker-to-local/"
backup_docker_to_local_folder: "{{path_administrator_scripts}}backup-docker-to-local/"

View File

@ -1,13 +1,13 @@
- name: "create {{docker_pull_primary_backups_folder}}"
- name: "create {{docker_backup_remote_to_local_folder}}"
file:
path: "{{docker_pull_primary_backups_folder}}"
path: "{{docker_backup_remote_to_local_folder}}"
state: directory
mode: 0755
- name: create backup-remote-to-local.sh
copy:
src: backup-remote-to-local.sh
dest: "{{docker_pull_primary_backups_folder}}backup-remote-to-local.sh"
dest: "{{docker_backup_remote_to_local_folder}}backup-remote-to-local.sh"
mode: 0755
- name: create backup-remote-to-local.service
@ -16,13 +16,13 @@
- 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
register: backup_backup_remote_to_local_timer
changed_when: backup_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
template:
src: backup-remote-to-local.sh.j2
dest: "{{docker_pull_primary_backups_folder}}backup-remote-to-local.sh"
dest: "{{docker_backup_remote_to_local_folder}}backup-remote-to-local.sh"
mode: 0755

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service cleanup-failed-docker-backups.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash {{docker_pull_primary_backups_folder}}backup-remote-to-local.sh
ExecStart=/usr/bin/bash {{docker_backup_remote_to_local_folder}}backup-remote-to-local.sh

View File

@ -3,6 +3,6 @@
hosts="{{pull_remote_backups}}";
errors=0
for host in $hosts; do
bash {{docker_pull_primary_backups_folder}}backup-remote-to-local.sh $host || ((errors+=1));
bash {{docker_backup_remote_to_local_folder}}backup-remote-to-local.sh $host || ((errors+=1));
done;
exit $errors;

View File

@ -2,7 +2,7 @@
Description=starts pull remote backup timer
[Timer]
OnCalendar={{on_calendar_pull_primary_backups}}
OnCalendar={{on_calendar_backup_remote_to_local}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=false

View File

@ -1 +1 @@
docker_pull_primary_backups_folder: "{{path_administrator_scripts}}pull-primary-backups/"
docker_backup_remote_to_local_folder: "{{path_administrator_scripts}}pull-primary-backups/"

View File

@ -5,16 +5,16 @@
- python-psutil
state: present
- name: "create {{docker_backups_cleanup}}"
- name: "create {{docker_cleanup_backups}}"
file:
path: "{{docker_backups_cleanup}}"
path: "{{docker_cleanup_backups}}"
state: directory
mode: 0755
- name: create cleanup-backups.py
copy:
src: "cleanup-backups.py"
dest: "{{docker_backups_cleanup}}cleanup-backups.py"
dest: "{{docker_cleanup_backups}}cleanup-backups.py"
- name: create cleanup-backups.service
template:

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/usr/bin/python {{docker_backups_cleanup}}cleanup-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}}
ExecStart=/usr/bin/python {{docker_cleanup_backups}}cleanup-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}}

View File

@ -1 +1 @@
docker_backups_cleanup: "{{path_administrator_scripts}}cleanup-backups/"
docker_cleanup_backups: "{{path_administrator_scripts}}cleanup-backups/"

View File

@ -2,7 +2,7 @@
Description=starts cleanup-backups.service
[Timer]
OnCalendar={{on_calendar_backups_cleanup}}
OnCalendar={{on_calendar_cleanup_backups}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=true

View File

@ -1,13 +1,13 @@
- name: "create {{free_disc_space_folder}}"
- name: "create {{cleanup_disc_space_folder}}"
file:
path: "{{free_disc_space_folder}}"
path: "{{cleanup_disc_space_folder}}"
state: directory
mode: 0755
- name: create cleanup-disc-space.sh
template:
src: cleanup-disc-space.sh.j2
dest: "{{free_disc_space_folder}}cleanup-disc-space.sh"
dest: "{{cleanup_disc_space_folder}}cleanup-disc-space.sh"
- name: create cleanup-disc-space.service
template:

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{free_disc_space_folder}}cleanup-disc-space.sh {{size_percent_free_disc_space}}
ExecStart=/bin/bash {{cleanup_disc_space_folder}}cleanup-disc-space.sh {{size_percent_cleanup_disc_space}}

View File

@ -2,8 +2,8 @@
# @param $1 mimimum free disc space
# @param $2 --force to for execution indepentend on how much disc space is free
execute_free_disc_space=0
minimum_percent_free_disc_space="$1"
execute_cleanup_disc_space=0
minimum_percent_cleanup_disc_space="$1"
force_freeing=false
echo "Checking free disc space..."
df
@ -14,12 +14,12 @@ fi
for disc_use_percent in $(df --output=pcent | sed 1d)
do
disc_use_percent_number=$(echo "$disc_use_percent" | sed "s/%//")
if [ "$disc_use_percent_number" -gt "$minimum_percent_free_disc_space" ]; then
if [ "$disc_use_percent_number" -gt "$minimum_percent_cleanup_disc_space" ]; then
echo "WARNING: $disc_use_percent_number exceeds the limit of {{size_percent_disc_space_warning}}%."
execute_free_disc_space+=1;
execute_cleanup_disc_space+=1;
fi
done
if [ "$disc_use_percent_number" -gt "$minimum_percent_free_disc_space" ] || [ "$force_freeing" = true ]; then
if [ "$disc_use_percent_number" -gt "$minimum_percent_cleanup_disc_space" ] || [ "$force_freeing" = true ]; then
echo "cleaning up /tmp" &&
find /tmp -type f -atime +10 -delete || exit 1

View File

@ -2,7 +2,7 @@
Description=starts cleanup-disc-space.service
[Timer]
OnCalendar={{on_calendar_free_disc_space}}
OnCalendar={{on_calendar_cleanup_disc_space}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=true

View File

@ -1 +1 @@
free_disc_space_folder: "{{path_administrator_scripts}}cleanup-disc-space/"
cleanup_disc_space_folder: "{{path_administrator_scripts}}cleanup-disc-space/"

View File

@ -1,7 +1,7 @@
- name: pull cleanup-failed-docker-backups.git
git:
repo: "https://github.com/kevinveenbirkenbach/cleanup-failed-docker-backups.git"
dest: "{{docker_volume_backup_cleanup_folder}}"
dest: "{{backup_docker_to_local_cleanup_folder}}"
update: yes
register: git_result
ignore_errors: true

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bash {{docker_volume_backup_cleanup_folder}}cleanup.sh {{docker_volume_backup_cleanup_machine_id}} {{docker_volume_backup_cleanup_trigger_directory}}'
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}}'

View File

@ -1 +1 @@
docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}cleanup-failed-docker-backups/"
backup_docker_to_local_cleanup_folder: "{{path_administrator_scripts}}cleanup-failed-docker-backups/"

View File

@ -1,13 +1,13 @@
- name: "create {{docker_compose_restart_unhealthy}}"
- name: "create {{heal_docker}}"
file:
path: "{{docker_compose_restart_unhealthy}}"
path: "{{heal_docker}}"
state: directory
mode: 0755
- name: create heal-docker.py
copy:
src: heal-docker.py
dest: "{{docker_compose_restart_unhealthy}}heal-docker.py"
dest: "{{heal_docker}}heal-docker.py"
- name: create heal-docker.service
template:

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/python {{docker_compose_restart_unhealthy}}heal-docker.py
ExecStart=/bin/python {{heal_docker}}heal-docker.py

View File

@ -2,7 +2,7 @@
Description=starts heal-docker.service
[Timer]
OnCalendar={{on_calendar_docker_compose_restart_unhealthy}}
OnCalendar={{on_calendar_heal_docker}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=false

View File

@ -1 +1 @@
docker_compose_restart_unhealthy: "{{path_administrator_scripts}}heal-docker/"
heal_docker: "{{path_administrator_scripts}}heal-docker/"

View File

@ -1,13 +1,13 @@
- name: "create {{docker_btrfs_health_check_folder}}"
- name: "create {{docker_health_btrfs_folder}}"
file:
path: "{{docker_btrfs_health_check_folder}}"
path: "{{docker_health_btrfs_folder}}"
state: directory
mode: 0755
- name: create health-btrfs.sh
copy:
src: health-btrfs.sh
dest: "{{docker_btrfs_health_check_folder}}health-btrfs.sh"
dest: "{{docker_health_btrfs_folder}}health-btrfs.sh"
- name: create health-btrfs.service
template:

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{docker_btrfs_health_check_folder}}health-btrfs.sh
ExecStart=/bin/bash {{docker_health_btrfs_folder}}health-btrfs.sh

View File

@ -2,7 +2,7 @@
Description=starts health-btrfs.service
[Timer]
OnCalendar={{on_calendar_btrfs_health_check}}
OnCalendar={{on_calendar_health_btrfs}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=false

View File

@ -1 +1 @@
docker_btrfs_health_check_folder: "{{path_administrator_scripts}}health-btrfs/"
docker_health_btrfs_folder: "{{path_administrator_scripts}}health-btrfs/"

View File

@ -1,14 +1,14 @@
#!/bin/sh
# @param $1 mimimum free disc space
errors=0
minimum_percent_free_disc_space="$1"
minimum_percent_cleanup_disc_space="$1"
echo "checking disc space use..."
df
for disc_use_percent in $(df --output=pcent | sed 1d)
do
disc_use_percent_number=$(echo "$disc_use_percent" | sed "s/%//")
if [ "$disc_use_percent_number" -gt "$minimum_percent_free_disc_space" ]; then
echo "WARNING: $disc_use_percent_number exceeds the limit of $minimum_percent_free_disc_space%."
if [ "$disc_use_percent_number" -gt "$minimum_percent_cleanup_disc_space" ]; then
echo "WARNING: $disc_use_percent_number exceeds the limit of $minimum_percent_cleanup_disc_space%."
errors+=1;
fi
done

View File

@ -1,13 +1,13 @@
- name: "create {{disc_space_check_folder}}"
- name: "create {{health_disc_space_folder}}"
file:
path: "{{disc_space_check_folder}}"
path: "{{health_disc_space_folder}}"
state: directory
mode: 0755
- name: create health-disc-space.sh
copy:
src: health-disc-space.sh
dest: "{{disc_space_check_folder}}health-disc-space.sh"
dest: "{{health_disc_space_folder}}health-disc-space.sh"
- name: create health-disc-space.service
template:

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{disc_space_check_folder}}health-disc-space.sh {{size_percent_disc_space_warning}}
ExecStart=/bin/bash {{health_disc_space_folder}}health-disc-space.sh {{size_percent_disc_space_warning}}

View File

@ -2,7 +2,7 @@
Description=starts health-disc-space.service
[Timer]
OnCalendar={{on_calendar_disc_space_check}}
OnCalendar={{on_calendar_health_disc_space}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=true

View File

@ -1 +1 @@
disc_space_check_folder: "{{path_administrator_scripts}}health-disc-space/"
health_disc_space_folder: "{{path_administrator_scripts}}health-disc-space/"

View File

@ -1,13 +1,13 @@
- name: "create {{docker_health_check_folder}}"
- name: "create {{health_docker_folder}}"
file:
path: "{{docker_health_check_folder}}"
path: "{{health_docker_folder}}"
state: directory
mode: 0755
- name: create health-docker.sh
copy:
src: health-docker.sh
dest: "{{docker_health_check_folder}}health-docker.sh"
dest: "{{health_docker_folder}}health-docker.sh"
- name: create health-docker.service
template: src=health-docker.service.j2 dest=/etc/systemd/system/health-docker.service

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{docker_health_check_folder}}health-docker.sh
ExecStart=/bin/bash {{health_docker_folder}}health-docker.sh

View File

@ -2,7 +2,7 @@
Description=starts health-docker.service
[Timer]
OnCalendar={{on_calendar_docker_health_check}}
OnCalendar={{on_calendar_health_docker}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=false

View File

@ -1 +1 @@
docker_health_check_folder: "{{path_administrator_scripts}}health-docker/"
health_docker_folder: "{{path_administrator_scripts}}health-docker/"

View File

@ -1,13 +1,13 @@
- name: "create {{journalctl_health_check_folder}}"
- name: "create {{health_journalctl_folder}}"
file:
path: "{{journalctl_health_check_folder}}"
path: "{{health_journalctl_folder}}"
state: directory
mode: 0755
- name: create health-journalctl.sh
copy:
src: health-journalctl.sh
dest: "{{journalctl_health_check_folder}}health-journalctl.sh"
dest: "{{health_journalctl_folder}}health-journalctl.sh"
- name: create health-journalctl.service
template:

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash {{journalctl_health_check_folder}}health-journalctl.sh
ExecStart=/bin/bash {{health_journalctl_folder}}health-journalctl.sh

View File

@ -2,7 +2,7 @@
Description=starts health-journalctl.service
[Timer]
OnCalendar={{on_calendar_journalctl_health_check}}
OnCalendar={{on_calendar_health_journalctl}}
RandomizedDelaySec={{randomized_delay_sec}}
Persistent=false

View File

@ -1 +1 @@
journalctl_health_check_folder: "{{path_administrator_scripts}}health-journalctl/"
health_journalctl_folder: "{{path_administrator_scripts}}health-journalctl/"

View File

@ -3,16 +3,16 @@
name: python-requests
state: present
- name: "create {{ nginx_health_check_folder }}"
- name: "create {{ health_nginx_folder }}"
file:
path: "{{ nginx_health_check_folder }}"
path: "{{ health_nginx_folder }}"
state: directory
mode: 0755
- name: create health-nginx.py
copy:
src: health-nginx.py
dest: "{{ nginx_health_check_folder }}health-nginx.py"
dest: "{{ health_nginx_folder }}health-nginx.py"
- name: create health-nginx.service
template:

View File

@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 {{ nginx_health_check_folder }}health-nginx.py
ExecStart=/usr/bin/python3 {{ health_nginx_folder }}health-nginx.py

View File

@ -2,7 +2,7 @@
Description=starts health-nginx.service
[Timer]
OnCalendar={{ on_calendar_nginx_health_check }}
OnCalendar={{ on_calendar_health_nginx }}
RandomizedDelaySec={{ randomized_delay_sec }}
Persistent=false

View File

@ -1 +1 @@
nginx_health_check_folder: "{{ path_administrator_scripts }}health-nginx/"
health_nginx_folder: "{{ path_administrator_scripts }}health-nginx/"