From 6b26ba444b0f16a8bfee5e1ae3d68853bb768cc4 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 19 Jul 2025 08:53:51 +0200 Subject: [PATCH] restic: Only set backup hostname if we have ansible fact For all backup containers. --- roles/arr/templates/compose.yaml.jinja | 2 +- roles/grocy/templates/compose.yaml.jinja | 2 +- roles/paperless/templates/compose.yaml.jinja | 2 +- roles/restic/templates/compose.yaml.jinja | 16 ++++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/roles/arr/templates/compose.yaml.jinja b/roles/arr/templates/compose.yaml.jinja index 847e366..19181dd 100644 --- a/roles/arr/templates/compose.yaml.jinja +++ b/roles/arr/templates/compose.yaml.jinja @@ -293,7 +293,7 @@ services: {% if restic_enable is not undefined and not false and arrstack_restic_enable is not undefined and not false %} backup: image: mazzolino/restic - hostname: "{{ ansible_hostname }}" + hostname: "{{ ansible_hostname | default() }}" environment: TZ: "{{ restic_tz }}" SKIP_INIT: true diff --git a/roles/grocy/templates/compose.yaml.jinja b/roles/grocy/templates/compose.yaml.jinja index e09a343..b3b1cc0 100644 --- a/roles/grocy/templates/compose.yaml.jinja +++ b/roles/grocy/templates/compose.yaml.jinja @@ -19,7 +19,7 @@ services: {% if restic_enable is not undefined and not false and stack_grocy_restic_enable is not undefined and not false %} backup: image: mazzolino/restic - hostname: "{{ ansible_hostname }}" + hostname: "{{ ansible_hostname | default() }}" environment: TZ: "{{ restic_tz }}" SKIP_INIT: true diff --git a/roles/paperless/templates/compose.yaml.jinja b/roles/paperless/templates/compose.yaml.jinja index c698b92..2bf7681 100644 --- a/roles/paperless/templates/compose.yaml.jinja +++ b/roles/paperless/templates/compose.yaml.jinja @@ -68,7 +68,7 @@ services: {% if restic_enable is not undefined and not false and stack_paperless_restic_enable is not undefined and not false %} backup: image: mazzolino/restic - hostname: "{{ ansible_hostname }}" + hostname: "{{ ansible_hostname | default() }}" environment: TZ: "{{ restic_tz }}" BACKUP_CRON: "{{ stack_paperless_restic_cron }}" diff --git a/roles/restic/templates/compose.yaml.jinja b/roles/restic/templates/compose.yaml.jinja index 306c522..65b4c5f 100644 --- a/roles/restic/templates/compose.yaml.jinja +++ b/roles/restic/templates/compose.yaml.jinja @@ -1,7 +1,7 @@ services: prune: image: "mazzolino/restic:{{ restic_version }}" - hostname: "{{ ansible_hostname }}" + hostname: "{{ ansible_hostname | default() }}" networks: - restic_notify environment: @@ -16,15 +16,15 @@ services: AWS_SECRET_ACCESS_KEY: "{{ restic_s3_secret }}" {% if restic_notify_success != None %} POST_COMMANDS_SUCCESS: |- - curl -X POST --data "{\"title\": \"Restic Prune successful\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_success:5000 + curl -X POST --data "{\"title\": \"Restic Prune successful\", \"body\": \"$HOSTNAME\"}" http://notify_success:5000 {% endif %} {% if restic_notify_failure != None %} POST_COMMANDS_FAILURE: |- - curl -X POST --data "{\"title\": \"Restic Prune failed\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_failure:5000 + curl -X POST --data "{\"title\": \"Restic Prune failed\", \"body\": \"$HOSTNAME\"}" http://notify_failure:5000 {% endif %} {% if restic_notify_exit != None %} POST_COMMANDS_EXIT: |- - curl -X POST --data "{\"title\": \"Restic Prune exited\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_exit:5000 + curl -X POST --data "{\"title\": \"Restic Prune exited\", \"body\": \"$HOSTNAME\"}" http://notify_exit:5000 {% endif %} {% if restic_repo is regex('^/.+') %} volumes: @@ -33,7 +33,7 @@ services: check: image: "mazzolino/restic:{{ restic_version }}" - hostname: docker + hostname: "{{ ansible_hostname | default() }}" networks: - restic_notify environment: @@ -48,15 +48,15 @@ services: AWS_SECRET_ACCESS_KEY: "{{ restic_s3_secret }}" {% if restic_notify_success != None %} POST_COMMANDS_SUCCESS: |- - curl -X POST --data "{\"title\": \"Restic Check successful\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_success:5000 + curl -X POST --data "{\"title\": \"Restic Check successful\", \"body\": \"$HOSTNAME\"}" http://notify_success:5000 {% endif %} {% if restic_notify_failure != None %} POST_COMMANDS_FAILURE: |- - curl -X POST --data "{\"title\": \"Restic Check failed\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_failure:5000 + curl -X POST --data "{\"title\": \"Restic Check failed\", \"body\": \"$HOSTNAME\"}" http://notify_failure:5000 {% endif %} {% if restic_notify_exit != None %} POST_COMMANDS_EXIT: |- - curl -X POST --data "{\"title\": \"Restic Check exited\", \"body\": \"{{ ansible_hostname }}\"}" http://notify_exit:5000 + curl -X POST --data "{\"title\": \"Restic Check exited\", \"body\": \"$HOSTNAME\"}" http://notify_exit:5000 {% endif %} {% if restic_repo is regex('^/.+') %} volumes: