/
/
/
Ansible role that can run restic backups and push it to a remote storage server.
1---
2- name: Assert restic repository and password provided
3 ansible.builtin.assert:
4 that:
5 - restic_repo | length > 0
6 - restic_password | length > 0
7 fail_msg: "restic_repo and restic_password must be set."
8
9- name: Assert backup_services is a list with at least one item
10 ansible.builtin.assert:
11 that:
12 - backup_services is iterable
13 - (backup_services | length) > 0
14 fail_msg: "backup_services must be a non-empty list."
15
16- name: Assert each service path exists
17 ansible.builtin.stat:
18 path: "{{ item.path }}"
19 loop: "{{ backup_services }}"
20 register: _svc_paths
21
22- name: Fail if any service path missing
23 ansible.builtin.fail:
24 msg: "Compose project path not found: {{ _svc_paths.results | selectattr('stat.exists','equalto',false) | map(attribute='item.path') | list }}"
25 when: _svc_paths.results | selectattr('stat.exists','equalto',false) | list | length > 0
26
27