ansible/roles/restic-client/tasks/main.yml

52 lines
1.0 KiB
YAML

---
- name: Install restic
apt:
update_cache: true
name:
- restic
state: present
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Ensures /etc/restic exists
file:
path: /etc/restic
state: directory
mode: 0700
owner: root
- name: Deploy restic config
template:
src: "{{ item }}.j2"
dest: /etc/{{ item }}
mode: 0600
owner: root
group: root
loop:
- restic/base.env
- restic/base-excludes
- restic/base-includes
- restic/base-password
- restic/base-repo
- systemd/system/restic-base.service
- systemd/system/restic-base.timer
notify: Restart timer
- name: Init restic repository
command:
cmd: "restic init --repository-file /etc/restic/base-repo --password-file /etc/restic/base-password"
register: restic_init
ignore_errors: true
- name: Indicate role in motd
template:
src: update-motd.d/04-service.j2
dest: /etc/update-motd.d/04-restic
mode: 0755
- name: Enable timer
service:
name: restic-base.timer
enabled: true