/
/
/
Ansible role that can run restic backups and push it to a remote storage server.
1---
2- name: Create restic environment
3 ansible.builtin.set_fact:
4 restic_environment: |
5 {
6 "RESTIC_REPOSITORY": "{{ restic_repo }}",
7 "RESTIC_PASSWORD": "{{ restic_password }}"
8 }
9 run_once: true
10
11- name: Add extra environment variables to restic environment
12 ansible.builtin.set_fact:
13 restic_environment: "{{ restic_environment | combine(restic_env_extra) }}"
14 run_once: true
15 when: restic_env_extra | length > 0
16
17- name: Check if restic repo is initialized
18 ansible.builtin.command: restic cat config
19 environment: "{{ restic_environment }}"
20 register: _restic_cat
21 failed_when: false
22 changed_when: false
23
24- name: Initialize restic repo if missing
25 ansible.builtin.command: restic init
26 environment: "{{ restic_environment }}"
27 when: _restic_cat.rc != 0
28
29