This playbook installs Restic, writes a protected environment file, and validates repository access.
- name: Configure restic backup host
hosts: restic
become: true
tasks:
- name: Install restic
ansible.builtin.package:
name: restic
state: present
- name: Create /etc/restic directory
ansible.builtin.file:
path: /etc/restic
state: directory
mode: "0750"
- name: Write restic env file
ansible.builtin.copy:
dest: /etc/restic/env
mode: "0600"
content: |
RESTIC_REPOSITORY="/srv/restic-repo"
RESTIC_PASSWORD_FILE="/etc/restic/password"
- name: Write restic password file
ansible.builtin.copy:
dest: /etc/restic/password
mode: "0600"
content: "change-me\n"
- name: Validate restic version
ansible.builtin.command: restic version
register: restic_version
changed_when: false
- name: Show restic version
ansible.builtin.debug:
var: restic_version.stdout_lines
restic init) before first scheduled backup.restic check jobs.