Refactored

This commit is contained in:
Kevin Veen-Birkenbach 2023-04-26 14:38:02 +02:00
parent 018c00f7b4
commit f78a759d7a
18 changed files with 30 additions and 27 deletions

View File

@ -16,6 +16,7 @@ on_calendar_docker_compose_restart_unhealthy: "*-*-* 09,10,11,12,13,14,15,16,17,
on_calendar_pull_primary_backups: "*-*-* 21:30:00"
on_calendar_renew_lets_encrypt_certificates: "*-*-* 12,00:30:00"
on_calendar_deploy_mailu_certificates: "*-*-* 13,01:30:00"
on_calendar_usb_auto_backup: "*-*-* 09,12,15,18,21,24,03,06:30:00"
# Space Variables
size_percent_maximum_backup: 75
@ -23,5 +24,7 @@ size_percent_disc_space_warning: 85
size_percent_free_disc_space: 90
# Path Variables
path_docker_volumes: "/home/administrator/volumes/docker/"
path_docker_compose_files: "/home/administrator/docker-compose/"
path_administrator_home: "/home/administrator/"
path_administrator_scripts: "{{path_administrator_home}}scripts/"
path_docker_volumes: "{{path_administrator_home}}volumes/docker/"
path_docker_compose_files: "{{path_administrator_home}}docker-compose/"

View File

@ -8,9 +8,9 @@
ssh_key_type: rsa
ssh_key_bits: 8192
- name: "create /home/administrator/scripts/"
- name: "create {{path_administrator_scripts}}"
file:
path: "/home/administrator/scripts"
path: "{{path_administrator_home}}scripts"
state: directory
owner: administrator
group: administrator

View File

@ -81,7 +81,7 @@ docker-compose build &&
docker-compose -p akaunting up -d --force-recreate
# recover all volumes
cd /home/administrator/scripts/docker-volume-backup &&
cd {{path_administrator_scripts}}docker-volume-backup &&
bash server_docker-volume-recover.sh akaunting_akaunting-modules ${machine_id:0:64} "$backup_version" &&
bash server_docker-volume-recover.sh akaunting_akaunting-data ${machine_id:0:64} "$backup_version" &&
bash server_docker-volume-recover.sh akaunting_akaunting-db ${machine_id:0:64} "$backup_version" akaunting-db "$akaunting_db_password" akaunting

View File

@ -15,9 +15,9 @@
state: directory
mode: 0755
- name: "create /home/administrator/scripts/mailu"
- name: "create {{path_administrator_scripts}}mailu"
file:
path: "/home/administrator/scripts/mailu"
path: "{{path_administrator_scripts}}mailu"
state: directory
mode: 0755
@ -48,7 +48,7 @@
- name: add deploy-letsencrypt-mailu.sh
template:
src: "deploy-letsencrypt-mailu.sh.j2"
dest: "/home/administrator/scripts/mailu/deploy-letsencrypt-mailu.sh"
dest: "{{path_administrator_scripts}}mailu/deploy-letsencrypt-mailu.sh"
- name: configure deploy-letsencrypt-mailu.service
template:

View File

@ -4,4 +4,4 @@ OnFailure=systemd-email@%n.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash /home/administrator/scripts/mailu/deploy-letsencrypt-mailu.sh
ExecStart=/usr/bin/bash {{path_administrator_scripts}}mailu/deploy-letsencrypt-mailu.sh

View File

@ -13,7 +13,7 @@ NEXTCLOUD_APPLICATION_DOCKER_CONTAINER=nextcloud-application-1
To update the nextcloud container execute the following commands on the server:
```bash
docker exec -it -u www-data $NEXTCLOUD_APPLICATION_DOCKER_CONTAINER /var/www/html/occ maintenance:mode --on
sudo python /home/administrator/scripts/docker-volume-backup/docker-volume-backup.py
sudo python {{path_administrator_scripts}}docker-volume-backup/docker-volume-backup.py
export COMPOSE_HTTP_TIMEOUT=600
export DOCKER_CLIENT_TIMEOUT=600
cd {{path_docker_compose_files}}nextcloud && docker-compose down
@ -58,7 +58,7 @@ and disable the not functioning apps.
cd {{path_docker_compose_files}}nextcloud &&
docker-compose down &&
docker exec -i nextcloud_database_1 mysql -u nextcloud -pPASSWORT nextcloud < "/Backups/$(sha256sum /etc/machine-id | head -c 64)/docker-volume-backup/latest/nextcloud_database/sql/backup.sql" &&
cd /home/administrator/scripts/docker-volume-backup &&
cd {{path_administrator_scripts}}docker-volume-backup &&
bash ./server_docker-volume-recover.sh "nextcloud_data" "$(sha256sum /etc/machine-id | head -c 64)"
```

View File

@ -1 +1 @@
docker_backups_cleanup: "/home/administrator/scripts/backups-cleanup/"
docker_backups_cleanup: "{{path_administrator_scripts}}backups-cleanup/"

View File

@ -1 +1 @@
docker_pull_primary_backups_folder: "/home/administrator/scripts/pull-primary-backups/"
docker_pull_primary_backups_folder: "{{path_administrator_scripts}}pull-primary-backups/"

View File

@ -1 +1 @@
docker_btrfs_health_check_folder: "/home/administrator/scripts/btrfs-health-check/"
docker_btrfs_health_check_folder: "{{path_administrator_scripts}}btrfs-health-check/"

View File

@ -1 +1 @@
disc_space_check_folder: "/home/administrator/scripts/disc-space-check/"
disc_space_check_folder: "{{path_administrator_scripts}}disc-space-check/"

View File

@ -1 +1 @@
docker_compose_restart_unhealthy: "/home/administrator/scripts/docker-compose-restart-unhealthy/"
docker_compose_restart_unhealthy: "{{path_administrator_scripts}}docker-compose-restart-unhealthy/"

View File

@ -1 +1 @@
docker_health_check_folder: "/home/administrator/scripts/server_docker-health-check/"
docker_health_check_folder: "{{path_administrator_scripts}}server_docker-health-check/"

View File

@ -1 +1 @@
docker_volume_backup_folder: "/home/administrator/scripts/docker-volume-backup/"
docker_volume_backup_folder: "{{path_administrator_scripts}}docker-volume-backup/"

View File

@ -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 /home/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}}backups-cleanup/backups-cleanup.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

View File

@ -1 +1 @@
free_disc_space_folder: "/home/administrator/scripts/free-disc-space/"
free_disc_space_folder: "{{path_administrator_scripts}}free-disc-space/"

View File

@ -1 +1 @@
journalctl_health_check_folder: "/home/administrator/scripts/journalctl-health-check/"
journalctl_health_check_folder: "{{path_administrator_scripts}}journalctl-health-check/"

View File

@ -1 +1 @@
systemd_email_folder: "/home/administrator/scripts/systemd_email/"
systemd_email_folder: "{{path_administrator_scripts}}systemd_email/"

View File

@ -1,7 +1,7 @@
- name: create /home/administrator/.ssh/authorized_keys
- name: create {{path_administrator_home}}.ssh/authorized_keys
copy:
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}/home/administrator/.ssh/authorized_keys"
dest: /home/administrator/.ssh/authorized_keys
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{path_administrator_home}}.ssh/authorized_keys"
dest: "{{path_administrator_home}}.ssh/authorized_keys"
owner: administrator
group: administrator
mode: '0644'
@ -15,9 +15,9 @@
group: root
notify: sshd restart
- name: "create /home/administrator/volumes/"
- name: "create {{path_administrator_home}}volumes/"
file:
path: "/home/administrator/volumes"
path: "{{path_administrator_home}}volumes"
state: directory
owner: administrator
group: administrator