/
/
/
Ansible role that can run restic backups and push it to a remote storage server.
1---
2- name: Check if restic repo is initialized
3 ansible.builtin.command: restic cat config
4 environment:
5 RESTIC_REPOSITORY: "{{ restic_repo }}"
6 RESTIC_PASSWORD: "{{ restic_password }}"
7 # Allow extra env (S3/B2/etc.)
8 {% for k, v in restic_env_extra.items() %}{{ k }}: "{{ v }}"
9 {% endfor %}
10 register: _restic_cat
11 failed_when: false
12 changed_when: false
13
14- name: Initialize restic repo if missing
15 ansible.builtin.command: restic init
16 environment:
17 RESTIC_REPOSITORY: "{{ restic_repo }}"
18 RESTIC_PASSWORD: "{{ restic_password }}"
19 {% for k, v in restic_env_extra.items() %}{{ k }}: "{{ v }}"
20 {% endfor %}
21 when: _restic_cat.rc != 0
22
23