linderhof/roles/restic/tasks/backend_sftp.yml
Matthias Johnson 796428cbda 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>
2026-03-01 21:24:45 -07:00

24 lines
784 B
YAML

---
- name: Deploy Restic SSH key
ansible.builtin.copy:
src: "{{ restic_local_key_path }}"
dest: "{{ restic_ssh_key }}"
owner: root
group: root
mode: '0600'
- name: Ensure restic repo directory exists on Storage Box
ansible.builtin.shell: |
ssh -i {{ restic_ssh_key }} -o BatchMode=yes -o StrictHostKeyChecking=no -p {{ restic_ssh_port }} {{ restic_user }}@{{ restic_host }} \
"mkdir -p {{ restic_remote_path }} && chmod 700 {{ restic_remote_path }}" < /dev/null
changed_when: false
- name: Write the ssh config for the root user
# TODO: this replaces roots config and should be much smarter, safe for me currently
template:
src: restic-ssh-config.j2
dest: /root/.ssh/config
mode: "0644"
- ansible.builtin.include_tasks: init.yml