/
/
/
Ansible role that can run restic backups and push it to a remote storage server.
1---
2- name: Install restic package
3 package:
4 name: "{{ backup_restic_pkg_name }}"
5 state: present
6 when: backup_install_restic | bool
7 tags: [restic, setup]
8
9- name: Build restic environment
10 ansible.builtin.set_fact:
11 restic_environment: "{{ {'RESTIC_REPOSITORY': restic_repo, 'RESTIC_PASSWORD': restic_password} | combine(restic_env_extra | default({})) }}"
12 run_once: true
13
14- name: Check if restic repo is initialized
15 ansible.builtin.command: restic cat config
16 environment: "{{ restic_environment }}"
17 register: _restic_cat
18 failed_when: false
19 changed_when: false
20 become: yes
21
22- name: Initialize restic repo if missing
23 ansible.builtin.command: restic init
24 environment: "{{ restic_environment }}"
25 when: _restic_cat.rc != 0
26 become: yes
27