mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-25 22:21:04 +01:00
Compare commits
20 Commits
dfc0dbbffa
...
29f134005f
Author | SHA1 | Date | |
---|---|---|---|
29f134005f | |||
333d1078f8 | |||
2170862d5f | |||
33bbd6a1df | |||
3b3737dc33 | |||
d2a728180f | |||
334aa9989b | |||
23ca62833f | |||
9bd6de8043 | |||
51006074b4 | |||
8d04397b91 | |||
41c1151f5a | |||
f237cf140c | |||
f0e5c2caa4 | |||
032ce50c77 | |||
40798d2294 | |||
9b0d744052 | |||
4b32bd1e5d | |||
407123492f | |||
10b04f8bd3 |
10
README.md
10
README.md
@ -30,12 +30,12 @@ This software allows to setup the docker following applications:
|
|||||||
#### Native Applications
|
#### Native Applications
|
||||||
|
|
||||||
This software shipts the following tools which are natively setup on the server:
|
This software shipts the following tools which are natively setup on the server:
|
||||||
- [Backups Cleanup](./roles/backups-cleanup-timer/README.md) - Cleans up old backups
|
- [Backups Cleanup](./roles/cleanup-backups-timer/README.md) - Cleans up old backups
|
||||||
- [Btrfs Health Check](./roles/btrfs-health-check/README.md) - Checks the health of Btrfs file systems
|
- [Btrfs Health Check](./roles/health-btrfs/README.md) - Checks the health of Btrfs file systems
|
||||||
- [Docker Health Check](./roles/docker-health-check/) - Checks the health of docker containers
|
- [Docker Health Check](./roles/health-docker/) - Checks the health of docker containers
|
||||||
- [Docker Reverse Proxy](./roles/docker-reverse-proxy/README.md) - Docker Reverse Proxy Solution
|
- [Docker Reverse Proxy](./roles/docker-reverse-proxy/README.md) - Docker Reverse Proxy Solution
|
||||||
- [Docker Volume Backup](./roles/docker-volume-backup/) - Backup Solution for Docker Volumes
|
- [Docker Volume Backup](./roles/backup-docker-to-local/) - Backup Solution for Docker Volumes
|
||||||
- [Pull Primary Backups](./roles/backups-consumer/README.md) - Pulls the backups from another server and stores them
|
- [Pull Primary Backups](./roles/backup-remote-to-local/README.md) - Pulls the backups from another server and stores them
|
||||||
- [Wireguard](./roles/wireguard/README.md) - Integrates the server in an wireguard vpn
|
- [Wireguard](./roles/wireguard/README.md) - Integrates the server in an wireguard vpn
|
||||||
|
|
||||||
### Server Administration
|
### Server Administration
|
||||||
|
12
playbook.yml
12
playbook.yml
@ -3,7 +3,7 @@
|
|||||||
hosts: all
|
hosts: all
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- system-update
|
- update
|
||||||
|
|
||||||
- name: servers host setup
|
- name: servers host setup
|
||||||
hosts: servers
|
hosts: servers
|
||||||
@ -11,9 +11,9 @@
|
|||||||
roles:
|
roles:
|
||||||
- system-security
|
- system-security
|
||||||
- journalctl
|
- journalctl
|
||||||
- disc-space-check
|
- health-disc-space
|
||||||
- free-disc-space
|
- cleanup-disc-space
|
||||||
- btrfs-health-check
|
- health-btrfs
|
||||||
|
|
||||||
# Wireguard Rollen
|
# Wireguard Rollen
|
||||||
- name: setup standard wireguard
|
- name: setup standard wireguard
|
||||||
@ -204,7 +204,7 @@
|
|||||||
hosts: replica_backup
|
hosts: replica_backup
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- role: backups-consumer
|
- role: backup-remote-to-local
|
||||||
|
|
||||||
## PC services
|
## PC services
|
||||||
- name: general host setup
|
- name: general host setup
|
||||||
@ -321,4 +321,4 @@
|
|||||||
hosts: backup_to_usb
|
hosts: backup_to_usb
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- backup-to-usb
|
- backup-data-to-usb
|
@ -1,4 +1,4 @@
|
|||||||
# backup-to-usb
|
# backup-data-to-usb
|
||||||
|
|
||||||
This Ansible role automates the process of performing backups to a swappable USB device.
|
This Ansible role automates the process of performing backups to a swappable USB device.
|
||||||
|
|
@ -21,7 +21,7 @@ def main():
|
|||||||
machine_id = subprocess.run(["sha256sum", "/etc/machine-id"], capture_output=True, text=True).stdout.strip()[:64]
|
machine_id = subprocess.run(["sha256sum", "/etc/machine-id"], capture_output=True, text=True).stdout.strip()[:64]
|
||||||
print(f"machine id: {machine_id}")
|
print(f"machine id: {machine_id}")
|
||||||
|
|
||||||
versions_path = os.path.join(backup_to_usb_destination_path, f"{machine_id}/backup-to-usb/")
|
versions_path = os.path.join(backup_to_usb_destination_path, f"{machine_id}/backup-data-to-usb/")
|
||||||
print(f"versions path: {versions_path}")
|
print(f"versions path: {versions_path}")
|
||||||
|
|
||||||
if not os.path.isdir(versions_path):
|
if not os.path.isdir(versions_path):
|
6
roles/backup-data-to-usb/handlers/main.yml
Normal file
6
roles/backup-data-to-usb/handlers/main.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
- name: "reload backup-data-to-usb.service"
|
||||||
|
systemd:
|
||||||
|
name: backup-data-to-usb.service
|
||||||
|
state: reloaded
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
3
roles/backup-data-to-usb/meta/main.yml
Normal file
3
roles/backup-data-to-usb/meta/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- role: cleanup-backups-service
|
@ -1,6 +1,6 @@
|
|||||||
- name: Copy backup script to the scripts directory
|
- name: Copy backup script to the scripts directory
|
||||||
copy:
|
copy:
|
||||||
src: backup-to-usb.python
|
src: backup-data-to-usb.python
|
||||||
dest: "{{ backup_to_usb_script_path }}"
|
dest: "{{ backup_to_usb_script_path }}"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
- name: Copy systemd service to systemd directory
|
- name: Copy systemd service to systemd directory
|
||||||
template:
|
template:
|
||||||
src: backup-to-usb.service.j2
|
src: backup-data-to-usb.service.j2
|
||||||
dest: /etc/systemd/system/backup-to-usb.service
|
dest: /etc/systemd/system/backup-data-to-usb.service
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
notify: reload backup-to-usb.service
|
notify: reload backup-data-to-usb.service
|
@ -5,7 +5,7 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/bin/python {{ backup_to_usb_script_path }} {{backup_to_usb_source}} {{backup_to_usb_destination}}
|
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]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
@ -1,4 +1,4 @@
|
|||||||
backup_to_usb_script_path: "/usr/local/sbin/backup-to-usb.python"
|
backup_to_usb_script_path: "/usr/local/sbin/backup-data-to-usb.python"
|
||||||
backup_to_usb_destination: "{{backup_to_usb_mount}}{{backup_to_usb_destination_subdirectory}}"
|
backup_to_usb_destination: "{{backup_to_usb_mount}}{{backup_to_usb_destination_subdirectory}}"
|
||||||
backups_folder_path: "{{backup_to_usb_destination}}"
|
backups_folder_path: "{{backup_to_usb_destination}}"
|
||||||
systemctl_mount_service_name: "{{ backup_to_usb_mount | trim('/') | replace('/', '-') }}.mount"
|
systemctl_mount_service_name: "{{ backup_to_usb_mount | trim('/') | replace('/', '-') }}.mount"
|
12
roles/backup-docker-to-local/handlers/main.yml
Normal file
12
roles/backup-docker-to-local/handlers/main.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
- name: "reload backup-docker-to-local.service"
|
||||||
|
systemd:
|
||||||
|
name: backup-docker-to-local.service
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
|
||||||
|
- name: "restart backup-docker-to-local.timer"
|
||||||
|
systemd:
|
||||||
|
name: backup-docker-to-local.timer
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
@ -2,4 +2,4 @@ dependencies:
|
|||||||
- git
|
- git
|
||||||
- backups-provider
|
- backups-provider
|
||||||
- systemd_notifier
|
- systemd_notifier
|
||||||
- docker-volume-backup-cleanup
|
- cleanup-failed-docker-backups
|
38
roles/backup-docker-to-local/tasks/main.yml
Normal file
38
roles/backup-docker-to-local/tasks/main.yml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
- name: install pandas system wide
|
||||||
|
community.general.pacman:
|
||||||
|
name:
|
||||||
|
- lsof
|
||||||
|
- python-pandas
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: pull backup-docker-to-local.git
|
||||||
|
git:
|
||||||
|
repo: "https://github.com/kevinveenbirkenbach/backup-docker-to-local.git"
|
||||||
|
dest: "{{docker_volume_backup_folder}}"
|
||||||
|
update: yes
|
||||||
|
register: git_result
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Warn if repo is not reachable
|
||||||
|
debug:
|
||||||
|
msg: "Warning: Repository is not reachable."
|
||||||
|
when: git_result.failed
|
||||||
|
|
||||||
|
- name: configure backup-docker-to-local.service
|
||||||
|
template:
|
||||||
|
src: backup-docker-to-local.service.j2
|
||||||
|
dest: /etc/systemd/system/backup-docker-to-local.service
|
||||||
|
notify: reload backup-docker-to-local.service
|
||||||
|
|
||||||
|
- 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
|
||||||
|
copy:
|
||||||
|
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{docker_volume_backup_folder}}databases.csv"
|
||||||
|
dest: "{{docker_volume_backup_folder}}databases.csv"
|
||||||
|
owner: root
|
||||||
|
group: root
|
@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=docker volume backup
|
||||||
|
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
|
1
roles/backup-docker-to-local/vars/main.yml
Normal file
1
roles/backup-docker-to-local/vars/main.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
docker_volume_backup_folder: "{{path_administrator_scripts}}backup-docker-to-local/"
|
@ -1,4 +1,4 @@
|
|||||||
# role backups-consumer
|
# role backup-remote-to-local
|
||||||
|
|
||||||
## goal
|
## goal
|
||||||
This script allows to pull backups from a remote server.
|
This script allows to pull backups from a remote server.
|
||||||
@ -15,17 +15,17 @@ To track what the service is doing execute one of the following commands:
|
|||||||
|
|
||||||
#### systemctl
|
#### systemctl
|
||||||
```bash
|
```bash
|
||||||
watch -n2 "systemctl status pull-remote-backups.service"
|
watch -n2 "systemctl status backup-remote-to-local.service"
|
||||||
```
|
```
|
||||||
|
|
||||||
#### journalctl
|
#### journalctl
|
||||||
```bash
|
```bash
|
||||||
journalctl -fu pull-remote-backups.service
|
journalctl -fu backup-remote-to-local.service
|
||||||
```
|
```
|
||||||
|
|
||||||
### history
|
### history
|
||||||
```bash
|
```bash
|
||||||
sudo journalctl -u pull-remote-backups
|
sudo journalctl -u backup-remote-to-local
|
||||||
```
|
```
|
||||||
|
|
||||||
## see
|
## see
|
11
roles/backup-remote-to-local/handlers/main.yml
Normal file
11
roles/backup-remote-to-local/handlers/main.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
- name: "reload backup-remote-to-local service"
|
||||||
|
systemd:
|
||||||
|
name: backup-remote-to-local.service
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
- name: "restart backup-remote-to-local timer"
|
||||||
|
systemd:
|
||||||
|
name: backup-remote-to-local.timer
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
5
roles/backup-remote-to-local/meta/main.yml
Normal file
5
roles/backup-remote-to-local/meta/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
dependencies:
|
||||||
|
- git
|
||||||
|
- systemd_notifier
|
||||||
|
- cleanup-backups-timer
|
||||||
|
- cleanup-failed-docker-backups
|
28
roles/backup-remote-to-local/tasks/main.yml
Normal file
28
roles/backup-remote-to-local/tasks/main.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
- name: "create {{docker_pull_primary_backups_folder}}"
|
||||||
|
file:
|
||||||
|
path: "{{docker_pull_primary_backups_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"
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: create backup-remote-to-local.service
|
||||||
|
template: src=backup-remote-to-local.service.j2 dest=/etc/systemd/system/backup-remote-to-local.service
|
||||||
|
notify: reload backup-remote-to-local service
|
||||||
|
|
||||||
|
- 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
|
||||||
|
template:
|
||||||
|
src: backup-remote-to-local.sh.j2
|
||||||
|
dest: "{{docker_pull_primary_backups_folder}}backup-remote-to-local.sh"
|
||||||
|
mode: 0755
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=pull remote backups
|
||||||
|
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
|
@ -3,6 +3,6 @@
|
|||||||
hosts="{{pull_remote_backups}}";
|
hosts="{{pull_remote_backups}}";
|
||||||
errors=0
|
errors=0
|
||||||
for host in $hosts; do
|
for host in $hosts; do
|
||||||
bash {{docker_pull_primary_backups_folder}}pull-remote-backup.sh $host || ((errors+=1));
|
bash {{docker_pull_primary_backups_folder}}backup-remote-to-local.sh $host || ((errors+=1));
|
||||||
done;
|
done;
|
||||||
exit $errors;
|
exit $errors;
|
@ -1,6 +0,0 @@
|
|||||||
- name: "reload backup-to-usb.service"
|
|
||||||
systemd:
|
|
||||||
name: backup-to-usb.service
|
|
||||||
state: reloaded
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
dependencies:
|
|
||||||
- role: backups-cleanup-service
|
|
@ -1,6 +0,0 @@
|
|||||||
- name: "reload backups-cleanup.service"
|
|
||||||
systemd:
|
|
||||||
name: backups-cleanup.service
|
|
||||||
state: reloaded
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,23 +0,0 @@
|
|||||||
- name: install lsof and python-psutil
|
|
||||||
community.general.pacman:
|
|
||||||
name:
|
|
||||||
- lsof
|
|
||||||
- python-psutil
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: "create {{docker_backups_cleanup}}"
|
|
||||||
file:
|
|
||||||
path: "{{docker_backups_cleanup}}"
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: create backups-cleanup.py
|
|
||||||
copy:
|
|
||||||
src: "backups-cleanup.py"
|
|
||||||
dest: "{{docker_backups_cleanup}}backups-cleanup.py"
|
|
||||||
|
|
||||||
- name: create backups-cleanup.service
|
|
||||||
template:
|
|
||||||
src: "backups-cleanup.service.j2"
|
|
||||||
dest: "/etc/systemd/system/backups-cleanup.service"
|
|
||||||
notify: reload backups-cleanup.service
|
|
@ -1 +0,0 @@
|
|||||||
docker_backups_cleanup: "{{path_administrator_scripts}}backups-cleanup/"
|
|
@ -1,2 +0,0 @@
|
|||||||
dependencies:
|
|
||||||
- backups-cleanup-service
|
|
@ -1,5 +0,0 @@
|
|||||||
- name: create backups-cleanup.timer
|
|
||||||
template:
|
|
||||||
src: "backups-cleanup.timer.j2"
|
|
||||||
dest: "/etc/systemd/system/backups-cleanup.timer"
|
|
||||||
notify: restart backups-cleanup.timer
|
|
@ -1,11 +0,0 @@
|
|||||||
- name: "reload pull-remote-backups service"
|
|
||||||
systemd:
|
|
||||||
name: pull-remote-backups.service
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
- name: "restart pull-remote-backups timer"
|
|
||||||
systemd:
|
|
||||||
name: pull-remote-backups.timer
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,5 +0,0 @@
|
|||||||
dependencies:
|
|
||||||
- git
|
|
||||||
- systemd_notifier
|
|
||||||
- backups-cleanup-timer
|
|
||||||
- docker-volume-backup-cleanup
|
|
@ -1,26 +0,0 @@
|
|||||||
- name: "create {{docker_pull_primary_backups_folder}}"
|
|
||||||
file:
|
|
||||||
path: "{{docker_pull_primary_backups_folder}}"
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: create pull-remote-backup.sh
|
|
||||||
copy:
|
|
||||||
src: pull-remote-backup.sh
|
|
||||||
dest: "{{docker_pull_primary_backups_folder}}pull-remote-backup.sh"
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: create pull-remote-backups.service
|
|
||||||
template: src=pull-remote-backups.service.j2 dest=/etc/systemd/system/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
|
|
||||||
notify: restart pull-remote-backups timer
|
|
||||||
|
|
||||||
- name: create pull-remote-backups.sh
|
|
||||||
template:
|
|
||||||
src: pull-remote-backups.sh.j2
|
|
||||||
dest: "{{docker_pull_primary_backups_folder}}pull-remote-backups.sh"
|
|
||||||
mode: 0755
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=pull remote backups
|
|
||||||
OnFailure=systemd-notifier@%n.service docker-volume-backup-cleanup.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/usr/bin/bash {{docker_pull_primary_backups_folder}}pull-remote-backups.sh
|
|
@ -12,8 +12,8 @@ hashed_machine_id="$($get_hashed_machine_id | head -c 64)"
|
|||||||
get_backup_types="find /Backups/$hashed_machine_id/ -maxdepth 1 -type d -execdir basename {} ;";
|
get_backup_types="find /Backups/$hashed_machine_id/ -maxdepth 1 -type d -execdir basename {} ;";
|
||||||
|
|
||||||
|
|
||||||
# @todo This configuration is not scalable yet. If other backup services then docker-volume-backup are integrated, this logic needs to be optimized
|
# @todo This configuration is not scalable yet. If other backup services then backup-docker-to-local are integrated, this logic needs to be optimized
|
||||||
get_version_directories="ls -d /Backups/$hashed_machine_id/docker-volume-backup/*"
|
get_version_directories="ls -d /Backups/$hashed_machine_id/backup-docker-to-local/*"
|
||||||
last_version_directory="$($get_version_directories | tail -1)"
|
last_version_directory="$($get_version_directories | tail -1)"
|
||||||
rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . $last_version_directory/"
|
rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . $last_version_directory/"
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
- backups-provider-user
|
- backups-provider-user
|
||||||
- backups-cleanup-timer
|
- cleanup-backups-timer
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
- name: "reload btrfs-health-check.service"
|
|
||||||
systemd:
|
|
||||||
name: btrfs-health-check.service
|
|
||||||
state: reloaded
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
- name: "restart btrfs-health-check.timer"
|
|
||||||
systemd:
|
|
||||||
name: btrfs-health-check.timer
|
|
||||||
state: restarted
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,22 +0,0 @@
|
|||||||
- name: "create {{docker_btrfs_health_check_folder}}"
|
|
||||||
file:
|
|
||||||
path: "{{docker_btrfs_health_check_folder}}"
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: create btrfs-health-check.sh
|
|
||||||
copy:
|
|
||||||
src: btrfs-health-check.sh
|
|
||||||
dest: "{{docker_btrfs_health_check_folder}}btrfs-health-check.sh"
|
|
||||||
|
|
||||||
- name: create btrfs-health-check.service
|
|
||||||
template:
|
|
||||||
src: btrfs-health-check.service.j2
|
|
||||||
dest: /etc/systemd/system/btrfs-health-check.service
|
|
||||||
notify: reload btrfs-health-check.service
|
|
||||||
|
|
||||||
- name: create 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
|
|
@ -13,4 +13,6 @@
|
|||||||
template:
|
template:
|
||||||
src: certbot.timer.j2
|
src: certbot.timer.j2
|
||||||
dest: /etc/systemd/system/certbot.timer
|
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
|
notify: restart certbot timer
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# role backups-cleanup-timer
|
# role cleanup-backups-timer
|
||||||
|
|
||||||
Cleans up old backups
|
Cleans up old backups
|
||||||
|
|
6
roles/cleanup-backups-service/handlers/main.yml
Normal file
6
roles/cleanup-backups-service/handlers/main.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
- name: "reload cleanup-backups.service"
|
||||||
|
systemd:
|
||||||
|
name: cleanup-backups.service
|
||||||
|
state: reloaded
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
23
roles/cleanup-backups-service/tasks/main.yml
Normal file
23
roles/cleanup-backups-service/tasks/main.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
- name: install lsof and python-psutil
|
||||||
|
community.general.pacman:
|
||||||
|
name:
|
||||||
|
- lsof
|
||||||
|
- python-psutil
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: "create {{docker_backups_cleanup}}"
|
||||||
|
file:
|
||||||
|
path: "{{docker_backups_cleanup}}"
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: create cleanup-backups.py
|
||||||
|
copy:
|
||||||
|
src: "cleanup-backups.py"
|
||||||
|
dest: "{{docker_backups_cleanup}}cleanup-backups.py"
|
||||||
|
|
||||||
|
- name: create cleanup-backups.service
|
||||||
|
template:
|
||||||
|
src: "cleanup-backups.service.j2"
|
||||||
|
dest: "/etc/systemd/system/cleanup-backups.service"
|
||||||
|
notify: reload cleanup-backups.service
|
@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
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}}
|
1
roles/cleanup-backups-service/vars/main.yml
Normal file
1
roles/cleanup-backups-service/vars/main.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
docker_backups_cleanup: "{{path_administrator_scripts}}cleanup-backups/"
|
@ -1,3 +1,3 @@
|
|||||||
# role backups-cleanup-timer
|
# role cleanup-backups-timer
|
||||||
|
|
||||||
Timer for cleaning up old backups
|
Timer for cleaning up old backups
|
@ -1,6 +1,6 @@
|
|||||||
- name: "restart backups-cleanup.timer"
|
- name: "restart cleanup-backups.timer"
|
||||||
systemd:
|
systemd:
|
||||||
name: backups-cleanup.timer
|
name: cleanup-backups.timer
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
2
roles/cleanup-backups-timer/meta/main.yml
Normal file
2
roles/cleanup-backups-timer/meta/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
- cleanup-backups-service
|
7
roles/cleanup-backups-timer/tasks/main.yml
Normal file
7
roles/cleanup-backups-timer/tasks/main.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
- name: create cleanup-backups.timer
|
||||||
|
template:
|
||||||
|
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
|
@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=starts backups-cleanup.service
|
Description=starts cleanup-backups.service
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar={{on_calendar_backups_cleanup}}
|
OnCalendar={{on_calendar_backups_cleanup}}
|
@ -1,4 +1,4 @@
|
|||||||
# free-disc-space
|
# cleanup-disc-space
|
||||||
Frees disc space
|
Frees disc space
|
||||||
## More information
|
## More information
|
||||||
- https://askubuntu.com/questions/380238/how-to-clean-tmp
|
- https://askubuntu.com/questions/380238/how-to-clean-tmp
|
12
roles/cleanup-disc-space/handlers/main.yml
Normal file
12
roles/cleanup-disc-space/handlers/main.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
- name: "reload cleanup-disc-space.service"
|
||||||
|
systemd:
|
||||||
|
name: cleanup-disc-space.service
|
||||||
|
state: reloaded
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
- name: "restart cleanup-disc-space.timer"
|
||||||
|
systemd:
|
||||||
|
name: cleanup-disc-space.timer
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
24
roles/cleanup-disc-space/tasks/main.yml
Normal file
24
roles/cleanup-disc-space/tasks/main.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
- name: "create {{free_disc_space_folder}}"
|
||||||
|
file:
|
||||||
|
path: "{{free_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"
|
||||||
|
|
||||||
|
- name: create cleanup-disc-space.service
|
||||||
|
template:
|
||||||
|
src: cleanup-disc-space.service.j2
|
||||||
|
dest: /etc/systemd/system/cleanup-disc-space.service
|
||||||
|
notify: reload cleanup-disc-space.service
|
||||||
|
|
||||||
|
- name: create cleanup-disc-space.timer
|
||||||
|
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
|
@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/bin/bash {{free_disc_space_folder}}free-disc-space.sh {{size_percent_free_disc_space}}
|
ExecStart=/bin/bash {{free_disc_space_folder}}cleanup-disc-space.sh {{size_percent_free_disc_space}}
|
@ -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 %}
|
{% if backups_folder_path is defined and size_percent_maximum_backup is defined %}
|
||||||
echo "cleaning up backups" &&
|
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 %}
|
{% endif %}
|
||||||
|
|
||||||
if pacman -Qs $package > /dev/null ; then
|
if pacman -Qs $package > /dev/null ; then
|
@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=starts free-disc-space.service
|
Description=starts cleanup-disc-space.service
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar={{on_calendar_free_disc_space}}
|
OnCalendar={{on_calendar_free_disc_space}}
|
1
roles/cleanup-disc-space/vars/main.yml
Normal file
1
roles/cleanup-disc-space/vars/main.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
free_disc_space_folder: "{{path_administrator_scripts}}cleanup-disc-space/"
|
3
roles/cleanup-failed-docker-backups/README.md
Normal file
3
roles/cleanup-failed-docker-backups/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Docker Volume Backup Cleanup
|
||||||
|
This script cleans up failed docker backups.
|
||||||
|
It uses https://github.com/kevinveenbirkenbach/cleanup-failed-docker-backups as base.
|
5
roles/cleanup-failed-docker-backups/handlers/main.yml
Normal file
5
roles/cleanup-failed-docker-backups/handlers/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
- name: "reload cleanup-failed-docker-backups.service daemon"
|
||||||
|
systemd:
|
||||||
|
name: cleanup-failed-docker-backups.service
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
18
roles/cleanup-failed-docker-backups/tasks/main.yml
Normal file
18
roles/cleanup-failed-docker-backups/tasks/main.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
- name: pull cleanup-failed-docker-backups.git
|
||||||
|
git:
|
||||||
|
repo: "https://github.com/kevinveenbirkenbach/cleanup-failed-docker-backups.git"
|
||||||
|
dest: "{{docker_volume_backup_cleanup_folder}}"
|
||||||
|
update: yes
|
||||||
|
register: git_result
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Warn if repo is not reachable
|
||||||
|
debug:
|
||||||
|
msg: "Warning: Repository is not reachable."
|
||||||
|
when: git_result.failed
|
||||||
|
|
||||||
|
- name: configure cleanup-failed-docker-backups.service
|
||||||
|
template:
|
||||||
|
src: cleanup-failed-docker-backups.service.j2
|
||||||
|
dest: /etc/systemd/system/cleanup-failed-docker-backups.service
|
||||||
|
notify: reload cleanup-failed-docker-backups.service daemon
|
@ -1 +1 @@
|
|||||||
docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}docker-volume-backup-cleanup/"
|
docker_volume_backup_cleanup_folder: "{{path_administrator_scripts}}cleanup-failed-docker-backups/"
|
@ -1,12 +0,0 @@
|
|||||||
- name: "reload disc-space-check.service"
|
|
||||||
systemd:
|
|
||||||
name: disc-space-check.service
|
|
||||||
state: reloaded
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
- name: "restart disc-space-check.timer"
|
|
||||||
systemd:
|
|
||||||
name: disc-space-check.timer
|
|
||||||
state: restarted
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,22 +0,0 @@
|
|||||||
- name: "create {{disc_space_check_folder}}"
|
|
||||||
file:
|
|
||||||
path: "{{disc_space_check_folder}}"
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: create disc-space-check.sh
|
|
||||||
copy:
|
|
||||||
src: disc-space-check.sh
|
|
||||||
dest: "{{disc_space_check_folder}}disc-space-check.sh"
|
|
||||||
|
|
||||||
- name: create disc-space-check.service
|
|
||||||
template:
|
|
||||||
src: disc-space-check.service.j2
|
|
||||||
dest: /etc/systemd/system/disc-space-check.service
|
|
||||||
notify: reload disc-space-check.service
|
|
||||||
|
|
||||||
- name: create disc-space-check.timer
|
|
||||||
template:
|
|
||||||
src: disc-space-check.timer.j2
|
|
||||||
dest: /etc/systemd/system/disc-space-check.timer
|
|
||||||
notify: restart disc-space-check.timer
|
|
@ -1,7 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=checking disc space
|
|
||||||
OnFailure=systemd-notifier@%n.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/bin/bash {{disc_space_check_folder}}disc-space-check.sh {{size_percent_disc_space_warning}}
|
|
@ -1 +0,0 @@
|
|||||||
disc_space_check_folder: "{{path_administrator_scripts}}disc-space-check/"
|
|
@ -81,7 +81,7 @@ docker-compose build &&
|
|||||||
docker-compose -p akaunting up -d --force-recreate
|
docker-compose -p akaunting up -d --force-recreate
|
||||||
|
|
||||||
# recover all volumes
|
# recover all volumes
|
||||||
cd {{path_administrator_scripts}}docker-volume-backup &&
|
cd {{path_administrator_scripts}}backup-docker-to-local &&
|
||||||
bash docker-volume-recover.sh akaunting_akaunting-modules ${machine_id:0:64} "$backup_version" &&
|
bash docker-volume-recover.sh akaunting_akaunting-modules ${machine_id:0:64} "$backup_version" &&
|
||||||
bash docker-volume-recover.sh akaunting_akaunting-data ${machine_id:0:64} "$backup_version" &&
|
bash docker-volume-recover.sh akaunting_akaunting-data ${machine_id:0:64} "$backup_version" &&
|
||||||
bash docker-volume-recover.sh akaunting_akaunting-db ${machine_id:0:64} "$backup_version" akaunting-db "$akaunting_db_password" akaunting
|
bash docker-volume-recover.sh akaunting_akaunting-db ${machine_id:0:64} "$backup_version" akaunting-db "$akaunting_db_password" akaunting
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
- name: "reload docker-compose-restart-unhealthy.service"
|
|
||||||
systemd:
|
|
||||||
name: docker-compose-restart-unhealthy.service
|
|
||||||
state: reloaded
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
- name: "restart docker-compose-restart-unhealthy.timer"
|
|
||||||
systemd:
|
|
||||||
name: docker-compose-restart-unhealthy.timer
|
|
||||||
state: restarted
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,22 +0,0 @@
|
|||||||
- name: "create {{docker_compose_restart_unhealthy}}"
|
|
||||||
file:
|
|
||||||
path: "{{docker_compose_restart_unhealthy}}"
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: create docker-compose-restart-unhealthy.py
|
|
||||||
copy:
|
|
||||||
src: docker-compose-restart-unhealthy.py
|
|
||||||
dest: "{{docker_compose_restart_unhealthy}}docker-compose-restart-unhealthy.py"
|
|
||||||
|
|
||||||
- name: create docker-compose-restart-unhealthy.service
|
|
||||||
template:
|
|
||||||
src: docker-compose-restart-unhealthy.service.j2
|
|
||||||
dest: /etc/systemd/system/docker-compose-restart-unhealthy.service
|
|
||||||
notify: reload docker-compose-restart-unhealthy.service
|
|
||||||
|
|
||||||
- name: create 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
|
|
@ -1,12 +0,0 @@
|
|||||||
- name: "reload docker-health-check.service"
|
|
||||||
systemd:
|
|
||||||
name: docker-health-check.service
|
|
||||||
state: reloaded
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
- name: "restart docker-health-check.timer"
|
|
||||||
systemd:
|
|
||||||
name: docker-health-check.timer
|
|
||||||
state: restarted
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,20 +0,0 @@
|
|||||||
- name: "create {{docker_health_check_folder}}"
|
|
||||||
file:
|
|
||||||
path: "{{docker_health_check_folder}}"
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: create docker-health-check.sh
|
|
||||||
copy:
|
|
||||||
src: docker-health-check.sh
|
|
||||||
dest: "{{docker_health_check_folder}}docker-health-check.sh"
|
|
||||||
|
|
||||||
- name: create docker-health-check.service
|
|
||||||
template: src=docker-health-check.service.j2 dest=/etc/systemd/system/docker-health-check.service
|
|
||||||
notify: reload docker-health-check.service
|
|
||||||
|
|
||||||
- name: create 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
|
|
@ -1 +0,0 @@
|
|||||||
docker_health_check_folder: "{{path_administrator_scripts}}docker-health-check/"
|
|
@ -60,4 +60,6 @@
|
|||||||
template:
|
template:
|
||||||
src: "deploy-letsencrypt-mailu.timer.j2"
|
src: "deploy-letsencrypt-mailu.timer.j2"
|
||||||
dest: "/etc/systemd/system/deploy-letsencrypt-mailu.timer"
|
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
|
notify: restart deploy-letsencrypt-mailu.timer
|
@ -59,8 +59,8 @@ and disable the not functioning apps.
|
|||||||
```bash
|
```bash
|
||||||
cd {{path_docker_compose_files}}nextcloud &&
|
cd {{path_docker_compose_files}}nextcloud &&
|
||||||
docker-compose down &&
|
docker-compose down &&
|
||||||
docker-compose exec -i database mysql -u nextcloud -pPASSWORT nextcloud < "/Backups/$(sha256sum /etc/machine-id | head -c 64)/docker-volume-backup/latest/nextcloud_database/sql/backup.sql" &&
|
docker-compose exec -i database mysql -u nextcloud -pPASSWORT nextcloud < "/Backups/$(sha256sum /etc/machine-id | head -c 64)/backup-docker-to-local/latest/nextcloud_database/sql/backup.sql" &&
|
||||||
cd {{path_administrator_scripts}}docker-volume-backup &&
|
cd {{path_administrator_scripts}}backup-docker-to-local &&
|
||||||
bash ./docker-volume-recover.sh "nextcloud_data" "$(sha256sum /etc/machine-id | head -c 64)"
|
bash ./docker-volume-recover.sh "nextcloud_data" "$(sha256sum /etc/machine-id | head -c 64)"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
# Docker Volume Backup Cleanup
|
|
||||||
This script cleans up failed docker backups.
|
|
||||||
It uses https://github.com/kevinveenbirkenbach/docker-volume-backup-cleanup as base.
|
|
@ -1,5 +0,0 @@
|
|||||||
- name: "reload docker-volume-backup-cleanup.service daemon"
|
|
||||||
systemd:
|
|
||||||
name: docker-volume-backup-cleanup.service
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,18 +0,0 @@
|
|||||||
- name: pull docker-volume-backup-cleanup.git
|
|
||||||
git:
|
|
||||||
repo: "https://github.com/kevinveenbirkenbach/docker-volume-backup-cleanup.git"
|
|
||||||
dest: "{{docker_volume_backup_cleanup_folder}}"
|
|
||||||
update: yes
|
|
||||||
register: git_result
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Warn if repo is not reachable
|
|
||||||
debug:
|
|
||||||
msg: "Warning: Repository is not reachable."
|
|
||||||
when: git_result.failed
|
|
||||||
|
|
||||||
- name: configure docker-volume-backup-cleanup.service
|
|
||||||
template:
|
|
||||||
src: docker-volume-backup-cleanup.service.j2
|
|
||||||
dest: /etc/systemd/system/docker-volume-backup-cleanup.service
|
|
||||||
notify: reload docker-volume-backup-cleanup.service daemon
|
|
@ -1,12 +0,0 @@
|
|||||||
- name: "reload docker-volume-backup.service"
|
|
||||||
systemd:
|
|
||||||
name: docker-volume-backup.service
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
|
|
||||||
- name: "restart docker-volume-backup.timer"
|
|
||||||
systemd:
|
|
||||||
name: docker-volume-backup.timer
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,36 +0,0 @@
|
|||||||
- name: install pandas system wide
|
|
||||||
community.general.pacman:
|
|
||||||
name:
|
|
||||||
- lsof
|
|
||||||
- python-pandas
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: pull docker-volume-backup.git
|
|
||||||
git:
|
|
||||||
repo: "https://github.com/kevinveenbirkenbach/docker-volume-backup.git"
|
|
||||||
dest: "{{docker_volume_backup_folder}}"
|
|
||||||
update: yes
|
|
||||||
register: git_result
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Warn if repo is not reachable
|
|
||||||
debug:
|
|
||||||
msg: "Warning: Repository is not reachable."
|
|
||||||
when: git_result.failed
|
|
||||||
|
|
||||||
- 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
|
|
||||||
notify: restart docker-volume-backup.timer
|
|
||||||
|
|
||||||
- name: create {{docker_volume_backup_folder}}databases.csv
|
|
||||||
copy:
|
|
||||||
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}{{docker_volume_backup_folder}}databases.csv"
|
|
||||||
dest: "{{docker_volume_backup_folder}}databases.csv"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
@ -1,7 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=docker volume backup
|
|
||||||
OnFailure=systemd-notifier@%n.service docker-volume-backup-cleanup.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/usr/bin/python {{docker_volume_backup_folder}}docker-volume-backup.py
|
|
@ -1 +0,0 @@
|
|||||||
docker_volume_backup_folder: "{{path_administrator_scripts}}docker-volume-backup/"
|
|
@ -1,5 +1,5 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
- docker-volume-backup
|
- backup-docker-to-local
|
||||||
- user-administrator
|
- user-administrator
|
||||||
- docker-health-check
|
- health-docker
|
||||||
- docker-compose-restart-unhealthy
|
- heal-docker
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: docker & docker compose install
|
- name: docker & docker compose install
|
||||||
pacman:
|
pacman:
|
||||||
name: ['docker','docker-compose']
|
name: ['docker','docker-compose']
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
- name: "reload free-disc-space.service"
|
|
||||||
systemd:
|
|
||||||
name: free-disc-space.service
|
|
||||||
state: reloaded
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
- name: "restart free-disc-space.timer"
|
|
||||||
systemd:
|
|
||||||
name: free-disc-space.timer
|
|
||||||
state: restarted
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@ -1,22 +0,0 @@
|
|||||||
- name: "create {{free_disc_space_folder}}"
|
|
||||||
file:
|
|
||||||
path: "{{free_disc_space_folder}}"
|
|
||||||
state: directory
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: create free-disc-space.sh
|
|
||||||
template:
|
|
||||||
src: free-disc-space.sh.j2
|
|
||||||
dest: "{{free_disc_space_folder}}free-disc-space.sh"
|
|
||||||
|
|
||||||
- name: create free-disc-space.service
|
|
||||||
template:
|
|
||||||
src: free-disc-space.service.j2
|
|
||||||
dest: /etc/systemd/system/free-disc-space.service
|
|
||||||
notify: reload free-disc-space.service
|
|
||||||
|
|
||||||
- name: create free-disc-space.timer
|
|
||||||
template:
|
|
||||||
src: free-disc-space.timer.j2
|
|
||||||
dest: /etc/systemd/system/free-disc-space.timer
|
|
||||||
notify: restart free-disc-space.timer
|
|
@ -1 +0,0 @@
|
|||||||
free_disc_space_folder: "{{path_administrator_scripts}}free-disc-space/"
|
|
@ -1,2 +1,2 @@
|
|||||||
# docker-compose-restart-unhealthy
|
# heal-docker
|
||||||
docker-compose restart for containers which are unhealty or excited
|
docker-compose restart for containers which are unhealty or excited
|
@ -27,16 +27,17 @@ def print_bash(command):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
waiting_time=600
|
waiting_time=600
|
||||||
backup_running=True
|
blocker_running=True
|
||||||
while backup_running:
|
while blocker_running:
|
||||||
try:
|
try:
|
||||||
bash("systemctl is-active --quiet docker-volume-backup.service")
|
bash("systemctl is-active --quiet backup-docker-to-local.service")
|
||||||
|
bash("systemctl is-active --quiet update-docker.service")
|
||||||
print("backup is running.")
|
print("backup is running.")
|
||||||
print("trying again in " + str(waiting_time) + " seconds.")
|
print("trying again in " + str(waiting_time) + " seconds.")
|
||||||
time.sleep(waiting_time)
|
time.sleep(waiting_time)
|
||||||
except:
|
except:
|
||||||
backup_running=False
|
blocker_running=False
|
||||||
print("no backup is running.")
|
print("No blocking service is running.")
|
||||||
|
|
||||||
unhealthy_container_names=print_bash('docker ps --filter health=unhealthy --format \'{{.Names}}\'')
|
unhealthy_container_names=print_bash('docker ps --filter health=unhealthy --format \'{{.Names}}\'')
|
||||||
exited_container_names=print_bash('docker ps --filter status=exited --format \'{{.Names}}\'')
|
exited_container_names=print_bash('docker ps --filter status=exited --format \'{{.Names}}\'')
|
12
roles/heal-docker/handlers/main.yml
Normal file
12
roles/heal-docker/handlers/main.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
- name: "reload heal-docker.service"
|
||||||
|
systemd:
|
||||||
|
name: heal-docker.service
|
||||||
|
state: reloaded
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
- name: "restart heal-docker.timer"
|
||||||
|
systemd:
|
||||||
|
name: heal-docker.timer
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
24
roles/heal-docker/tasks/main.yml
Normal file
24
roles/heal-docker/tasks/main.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
- name: "create {{docker_compose_restart_unhealthy}}"
|
||||||
|
file:
|
||||||
|
path: "{{docker_compose_restart_unhealthy}}"
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: create heal-docker.py
|
||||||
|
copy:
|
||||||
|
src: heal-docker.py
|
||||||
|
dest: "{{docker_compose_restart_unhealthy}}heal-docker.py"
|
||||||
|
|
||||||
|
- name: create heal-docker.service
|
||||||
|
template:
|
||||||
|
src: heal-docker.service.j2
|
||||||
|
dest: /etc/systemd/system/heal-docker.service
|
||||||
|
notify: reload heal-docker.service
|
||||||
|
|
||||||
|
- name: create heal-docker.timer
|
||||||
|
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
|
@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/bin/python {{docker_compose_restart_unhealthy}}docker-compose-restart-unhealthy.py
|
ExecStart=/bin/python {{docker_compose_restart_unhealthy}}heal-docker.py
|
@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=starts docker-compose-restart-unhealthy.service
|
Description=starts heal-docker.service
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar={{on_calendar_docker_compose_restart_unhealthy}}
|
OnCalendar={{on_calendar_docker_compose_restart_unhealthy}}
|
@ -1 +1 @@
|
|||||||
docker_compose_restart_unhealthy: "{{path_administrator_scripts}}docker-compose-restart-unhealthy/"
|
docker_compose_restart_unhealthy: "{{path_administrator_scripts}}heal-docker/"
|
@ -1,4 +1,4 @@
|
|||||||
# btrfs-health-check
|
# health-btrfs
|
||||||
|
|
||||||
Sends a health report
|
Sends a health report
|
||||||
|
|
12
roles/health-btrfs/handlers/main.yml
Normal file
12
roles/health-btrfs/handlers/main.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
- name: "reload health-btrfs.service"
|
||||||
|
systemd:
|
||||||
|
name: health-btrfs.service
|
||||||
|
state: reloaded
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
- name: "restart health-btrfs.timer"
|
||||||
|
systemd:
|
||||||
|
name: health-btrfs.timer
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user