diff --git a/inventory/serguzim.net.yml b/inventory/serguzim.net.yml index d717402..262b65d 100644 --- a/inventory/serguzim.net.yml +++ b/inventory/serguzim.net.yml @@ -10,26 +10,26 @@ all: node002: ansible_host: "{{ opentofu.hosts.node002.fqdn_vpn }}" - ansible_port: "{{ vault_node002.ansible_port }}" - ansible_user: "{{ vault_node002.ansible_user }}" - interactive_user: "{{ vault_node002.interactive_user }}" + ansible_port: "{{ vault_hosts.node002.ansible_port }}" + ansible_user: "{{ vault_hosts.node002.ansible_user }}" + interactive_user: "{{ vault_hosts.node002.interactive_user }}" host_vpn: domain: "{{ opentofu.hosts.node002.fqdn_vpn }}" ip: "{{ opentofu.hosts.node002.ipv4_address_vpn }}" host_backup: hc_uid: "{{ opentofu.healthchecksio.backup.node002.id }}" hc_url: "{{ opentofu.healthchecksio.backup.node002.ping_url }}" - uptime_kuma_token: "{{ vault_node002.backup.uptime_kuma_token }}" + gatus_token: "{{ vault_hosts.node002.backup.gatus_token }}" node003: ansible_host: "{{ opentofu.hosts.node003.fqdn_vpn }}" - ansible_port: "{{ vault_node003.ansible_port }}" - ansible_user: "{{ vault_node003.ansible_user }}" - interactive_user: "{{ vault_node003.interactive_user }}" + ansible_port: "{{ vault_hosts.node003.ansible_port }}" + ansible_user: "{{ vault_hosts.node003.ansible_user }}" + interactive_user: "{{ vault_hosts.node003.interactive_user }}" host_vpn: domain: "{{ opentofu.hosts.node003.fqdn_vpn }}" ip: "{{ opentofu.hosts.node003.ipv4_address_vpn }}" host_backup: hc_uid: "{{ opentofu.healthchecksio.backup.node003.id }}" hc_url: "{{ opentofu.healthchecksio.backup.node003.ping_url }}" - uptime_kuma_token: "{{ vault_node003.backup.uptime_kuma_token }}" + gatus_token: "{{ vault_hosts.node003.backup.gatus_token }}" diff --git a/playbooks/filter_plugins/map_backup_locations.py b/playbooks/filter_plugins/map_backup_locations.py index 193d543..5f35a15 100644 --- a/playbooks/filter_plugins/map_backup_locations.py +++ b/playbooks/filter_plugins/map_backup_locations.py @@ -15,7 +15,7 @@ class FilterModule(object): new_location = { "to": backends_list, - "forget": "yes", + "forget": "no", "hooks": copy.deepcopy(hooks) } diff --git a/roles/backup/tasks/main.yml b/roles/backup/tasks/main.yml index b62eb90..2cff5a3 100644 --- a/roles/backup/tasks/main.yml +++ b/roles/backup/tasks/main.yml @@ -32,3 +32,7 @@ chdir: "{{ service_path }}" changed_when: false become: true + register: cmd_result_verify + until: "cmd_result_verify is not failed" + retries: 10 + delay: 10 diff --git a/roles/backup/templates/backup.sh.j2 b/roles/backup/templates/backup.sh.j2 index c3c8a05..56db0de 100644 --- a/roles/backup/templates/backup.sh.j2 +++ b/roles/backup/templates/backup.sh.j2 @@ -5,8 +5,8 @@ if autorestic backup -av --ci then {{ backup_hc_command_success }} - {{ backup_uk_command_success }} + {{ backup_gatus_command_success }} else {{ backup_hc_command_fail }} - {{ backup_uk_command_fail }} + {{ backup_gatus_command_fail }} fi diff --git a/roles/backup/vars/main.yml b/roles/backup/vars/main.yml index 06dd8a6..4291e3c 100644 --- a/roles/backup/vars/main.yml +++ b/roles/backup/vars/main.yml @@ -12,29 +12,33 @@ backup_msg_success: "Backup successful" backup_curl_base: 'curl -L -m 10 --retry 5' backup_hc_curl_base: '{{ backup_curl_base }} -X POST -H "Content-Type: text/plain"' -backup_uk_curl_base: '{{ backup_curl_base }}' +backup_gatus_curl_base: '{{ backup_curl_base }} -X POST -H "Authorization: Bearer {{ host_backup.gatus_token }}"' backup_hc_url: '{{ host_backup.hc_url }}' -backup_uk_url: 'https://status.serguzim.me/api/push/{{ host_backup.uptime_kuma_token }}' +backup_gatus_url: 'https://status.serguzim.me/api/v1/endpoints/8-backups_backup@{{ ansible_facts.hostname }}/external' backup_hc_command_start: '{{ backup_hc_curl_base }} --data "{{ backup_msg_start }}" {{ backup_hc_url }}/start' backup_hc_command_success: '{{ backup_hc_curl_base }} --data "{{ backup_msg_success }}" {{ backup_hc_url }}' -backup_uk_command_success: '{{ backup_uk_curl_base }} "{{ backup_uk_url }}?status=up&msg={{ backup_msg_success | urlencode }}&ping="' backup_hc_command_fail: '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail }}" {{ backup_hc_url }}/fail' -backup_uk_command_fail: '{{ backup_uk_curl_base }} "{{ backup_uk_url }}?status=down&msg={{ backup_msg_fail | urlencode }}&ping="' + +backup_gatus_command_success: '{{ backup_gatus_curl_base }} "{{ backup_gatus_url }}?success=true"' +backup_gatus_command_fail: '{{ backup_gatus_curl_base }} "{{ backup_gatus_url }}?success=false&error={{ backup_msg_fail | urlencode }}"' backup_default_hooks: failure: - '{{ backup_hc_curl_base }} --data "{{ backup_msg_fail_location }}${AUTORESTIC_LOCATION}" {{ backup_hc_url }}/fail' - - '{{ backup_uk_curl_base }} "{{ backup_uk_url }}?status=down&msg={{ backup_msg_fail_location | urlencode }}${AUTORESTIC_LOCATION}&ping="' + - '{{ backup_gatus_curl_base }} "{{ backup_gatus_url }}?success=false&error={{ backup_msg_fail_location | urlencode }}${AUTORESTIC_LOCATION}' backup_yml: version: 2 - backends: "{{ vault_backup.locations }}" + backends: "{{ vault_backup.backends }}" - locations: "{{ backup_list | map_backup_locations(vault_backup.locations, backup_default_hooks ) }}" + 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