Add autorestic.all file and move two services
This commit is contained in:
parent
aa9c76a622
commit
c28a195f49
4 changed files with 37 additions and 16 deletions
|
@ -8,7 +8,8 @@ class FilterModule(object):
|
||||||
def my_service_attributes(self, services, host, attribute="name"):
|
def my_service_attributes(self, services, host, attribute="name"):
|
||||||
result = []
|
result = []
|
||||||
for service in services:
|
for service in services:
|
||||||
if service["host"] != host:
|
# only compare the host if it is set
|
||||||
|
if host and service["host"] != host:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
attribute_value = service.get(attribute)
|
attribute_value = service.get(attribute)
|
||||||
|
|
|
@ -21,6 +21,14 @@
|
||||||
dest: "{{ (service_path, '.autorestic.yml') | path_join }}"
|
dest: "{{ (service_path, '.autorestic.yml') | path_join }}"
|
||||||
mode: "0644"
|
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
|
- name: Import tasks specific to the hooks scripts
|
||||||
ansible.builtin.import_tasks: hooks.yml
|
ansible.builtin.import_tasks: hooks.yml
|
||||||
- name: Import tasks specific to systemd
|
- name: Import tasks specific to systemd
|
||||||
|
|
|
@ -4,6 +4,7 @@ backup_svc:
|
||||||
name: backup
|
name: backup
|
||||||
|
|
||||||
backup_list: "{{ all_services | my_service_attributes(inventory_hostname, '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_start: "Backup started"
|
||||||
backup_msg_fail: "Backup failed"
|
backup_msg_fail: "Backup failed"
|
||||||
|
@ -28,14 +29,7 @@ backup_default_hooks:
|
||||||
- '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail_location }}${AUTORESTIC_LOCATION}" {{ backup_hc_url }}/fail'
|
- '{{ 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_gatus_curl_base }} "{{ backup_gatus_url }}?success=false&error={{ backup_msg_fail_location | urlencode }}${AUTORESTIC_LOCATION}'
|
||||||
|
|
||||||
backup_yml:
|
backup_global:
|
||||||
version: 2
|
|
||||||
|
|
||||||
backends: "{{ vault_backup.backends }}"
|
|
||||||
|
|
||||||
locations: "{{ backup_list | map_backup_locations(vault_backup.backends, backup_default_hooks ) }}"
|
|
||||||
|
|
||||||
global:
|
|
||||||
all:
|
all:
|
||||||
cache-dir: "{{ (service_path, 'cache') | path_join }}"
|
cache-dir: "{{ (service_path, 'cache') | path_join }}"
|
||||||
retry-lock: 5m
|
retry-lock: 5m
|
||||||
|
@ -48,3 +42,21 @@ backup_yml:
|
||||||
host: "{{ ansible_facts.hostname }}"
|
host: "{{ ansible_facts.hostname }}"
|
||||||
backup:
|
backup:
|
||||||
host: "{{ ansible_facts.hostname }}"
|
host: "{{ ansible_facts.hostname }}"
|
||||||
|
|
||||||
|
backup_yml:
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
backends: "{{ vault_backup.backends }}"
|
||||||
|
|
||||||
|
locations: "{{ backup_list | map_backup_locations(vault_backup.backends, backup_default_hooks ) }}"
|
||||||
|
|
||||||
|
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 }}"
|
||||||
|
|
|
@ -123,7 +123,7 @@ services = {
|
||||||
|
|
||||||
"homebox" = {
|
"homebox" = {
|
||||||
name = "homebox"
|
name = "homebox"
|
||||||
host = "node002"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "serguzim.me"
|
||||||
target = "inventory"
|
target = "inventory"
|
||||||
|
@ -285,7 +285,7 @@ services = {
|
||||||
|
|
||||||
"ntfy" = {
|
"ntfy" = {
|
||||||
name = "ntfy"
|
name = "ntfy"
|
||||||
host = "node002"
|
host = "node003"
|
||||||
dns = [{
|
dns = [{
|
||||||
domain = "serguzim.me"
|
domain = "serguzim.me"
|
||||||
target = "push"
|
target = "push"
|
||||||
|
|
Loading…
Reference in a new issue