Extract restic repo init to shared task file

Deduplicate nearly identical init logic from backend.yml and
backend_sftp.yml into init.yml. Also fixes missing set -euo pipefail
in the sftp backend variant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthias Johnson 2026-03-01 21:24:45 -07:00
parent 16da843131
commit 796428cbda
3 changed files with 11 additions and 15 deletions

View file

@ -8,12 +8,5 @@
mode: "0700"
when: restic_repo is defined and restic_repo.startswith('/') # only local path
- name: Ensure restic repo is initialized
ansible.builtin.shell: |
set -euo pipefail
source /etc/restic/restic.env
restic snapshots > /dev/null 2>&1 || restic init
touch /etc/restic/.initialized
args:
creates: /etc/restic/.initialized
- ansible.builtin.include_tasks: init.yml