1 Commits
Author SHA1 Message Date
alessandrovitali c362460b86 fix fragile tasks 2026-09-03 20:39:45 +02:00
+8 -15
View File
@@ -1,20 +1,19 @@
---
- name: Install and initialize restic
become: true
environment:
RESTIC_REPOSITORY: "{{ vault_restic_repo_url }}"
RESTIC_PASSWORD: "{{ vault_restic_password }}"
AWS_ACCESS_KEY_ID: "{{ vault_aws_access_key }}"
AWS_SECRET_ACCESS_KEY: "{{ vault_aws_secret_key }}"
block:
- name: Install restic
ansible.builtin.apt:
name: restic
state: present
update_cache: true
- name: Initialize restic repository
environment:
RESTIC_REPOSITORY: "{{ vault_restic_repo_url }}"
RESTIC_PASSWORD: "{{ vault_restic_password }}"
AWS_ACCESS_KEY_ID: "{{ vault_aws_access_key }}"
AWS_SECRET_ACCESS_KEY: "{{ vault_aws_secret_key }}"
block:
- name: Check if repository is initialized
ansible.builtin.command: restic cat config
command: restic cat config
register: restic_check
changed_when: false
failed_when: false
@@ -23,9 +22,6 @@
ansible.builtin.command: restic init
when: restic_check.rc != 0
- name: Configure restic backup job
become: true
block:
- name: Deploy restic environment file
ansible.builtin.template:
src: restic-backup.env.j2
@@ -42,9 +38,6 @@
group: root
mode: "0700" ## only root can execute the script
- name: Schedule restic backups
become: true
block:
- name: Deploy restic systemd service
ansible.builtin.template:
src: restic-backup.service.j2