Add autorestic.all file and move two services

This commit is contained in:
Tobias Reisinger 2024-10-08 00:54:09 +02:00
parent aa9c76a622
commit c28a195f49
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
4 changed files with 37 additions and 16 deletions

View file

@ -8,7 +8,8 @@ class FilterModule(object):
def my_service_attributes(self, services, host, attribute="name"):
result = []
for service in services:
if service["host"] != host:
# only compare the host if it is set
if host and service["host"] != host:
continue
attribute_value = service.get(attribute)

View file

@ -21,6 +21,14 @@
dest: "{{ (service_path, '.autorestic.yml') | path_join }}"
mode: "0644"
- name: Template autorestic.all.yml
ansible.builtin.template:
src: yml.j2
dest: "{{ (service_path, '.autorestic.all.yml') | path_join }}"
mode: "0644"
vars:
yml: "{{ backup_yml_all }}"
- name: Import tasks specific to the hooks scripts
ansible.builtin.import_tasks: hooks.yml
- name: Import tasks specific to systemd

View file

@ -4,6 +4,7 @@ backup_svc:
name: backup
backup_list: "{{ all_services | my_service_attributes(inventory_hostname, 'backup') }}"
backup_list_all: "{{ all_services | my_service_attributes('', 'backup') }}"
backup_msg_start: "Backup started"
backup_msg_fail: "Backup failed"
@ -28,6 +29,20 @@ backup_default_hooks:
- '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail_location }}${AUTORESTIC_LOCATION}" {{ backup_hc_url }}/fail'
- '{{ backup_gatus_curl_base }} "{{ backup_gatus_url }}?success=false&error={{ backup_msg_fail_location | urlencode }}${AUTORESTIC_LOCATION}'
backup_global:
all:
cache-dir: "{{ (service_path, 'cache') | path_join }}"
retry-lock: 5m
forget:
keep-last: 7
keep-daily: 14
keep-weekly: 16
keep-monthly: 12
keep-yearly: 2
host: "{{ ansible_facts.hostname }}"
backup:
host: "{{ ansible_facts.hostname }}"
backup_yml:
version: 2
@ -35,16 +50,13 @@ backup_yml:
locations: "{{ backup_list | map_backup_locations(vault_backup.backends, backup_default_hooks ) }}"
global:
all:
cache-dir: "{{ (service_path, 'cache') | path_join }}"
retry-lock: 5m
forget:
keep-last: 7
keep-daily: 14
keep-weekly: 16
keep-monthly: 12
keep-yearly: 2
host: "{{ ansible_facts.hostname }}"
backup:
host: "{{ ansible_facts.hostname }}"
global: "{{ backup_global }}"
backup_yml_all:
version: 2
backends: "{{ vault_backup.backends }}"
locations: "{{ backup_list_all | map_backup_locations(vault_backup.backends, backup_default_hooks ) }}"
global: "{{ backup_global }}"

View file

@ -123,7 +123,7 @@ services = {
"homebox" = {
name = "homebox"
host = "node002"
host = "node003"
dns = [{
domain = "serguzim.me"
target = "inventory"
@ -285,7 +285,7 @@ services = {
"ntfy" = {
name = "ntfy"
host = "node002"
host = "node003"
dns = [{
domain = "serguzim.me"
target = "push"