1 Commits
Author SHA1 Message Date
alessandrovitali c362460b86 fix fragile tasks 2026-09-03 20:39:45 +02:00
+13 -20
View File
@@ -1,20 +1,19 @@
--- ---
- name: Install and initialize restic - name: Install restic
become: true ansible.builtin.apt:
name: restic
state: present
update_cache: true
- name: Initialize restic repository
environment: environment:
RESTIC_REPOSITORY: "{{ vault_restic_repo_url }}" RESTIC_REPOSITORY: "{{ vault_restic_repo_url }}"
RESTIC_PASSWORD: "{{ vault_restic_password }}" RESTIC_PASSWORD: "{{ vault_restic_password }}"
AWS_ACCESS_KEY_ID: "{{ vault_aws_access_key }}" AWS_ACCESS_KEY_ID: "{{ vault_aws_access_key }}"
AWS_SECRET_ACCESS_KEY: "{{ vault_aws_secret_key }}" AWS_SECRET_ACCESS_KEY: "{{ vault_aws_secret_key }}"
block: block:
- name: Install restic
ansible.builtin.apt:
name: restic
state: present
update_cache: true
- name: Check if repository is initialized - name: Check if repository is initialized
ansible.builtin.command: restic cat config command: restic cat config
register: restic_check register: restic_check
changed_when: false changed_when: false
failed_when: false failed_when: false
@@ -23,10 +22,7 @@
ansible.builtin.command: restic init ansible.builtin.command: restic init
when: restic_check.rc != 0 when: restic_check.rc != 0
- name: Configure restic backup job - name: Deploy restic environment file
become: true
block:
- name: Deploy restic environment file
ansible.builtin.template: ansible.builtin.template:
src: restic-backup.env.j2 src: restic-backup.env.j2
dest: /etc/restic-backup.env dest: /etc/restic-backup.env
@@ -34,7 +30,7 @@
group: root group: root
mode: "0600" ## only root can read this file mode: "0600" ## only root can read this file
- name: Deploy restic backup script - name: Deploy restic backup script
ansible.builtin.template: ansible.builtin.template:
src: restic-backup.sh.j2 src: restic-backup.sh.j2
dest: /usr/local/bin/restic-backup.sh dest: /usr/local/bin/restic-backup.sh
@@ -42,10 +38,7 @@
group: root group: root
mode: "0700" ## only root can execute the script mode: "0700" ## only root can execute the script
- name: Schedule restic backups - name: Deploy restic systemd service
become: true
block:
- name: Deploy restic systemd service
ansible.builtin.template: ansible.builtin.template:
src: restic-backup.service.j2 src: restic-backup.service.j2
dest: /etc/systemd/system/restic-backup.service dest: /etc/systemd/system/restic-backup.service
@@ -53,7 +46,7 @@
group: root group: root
mode: "0644" mode: "0644"
- name: Deploy restic systemd timer - name: Deploy restic systemd timer
ansible.builtin.template: ansible.builtin.template:
src: restic-backup.timer.j2 src: restic-backup.timer.j2
dest: /etc/systemd/system/restic-backup.timer dest: /etc/systemd/system/restic-backup.timer
@@ -61,7 +54,7 @@
group: root group: root
mode: "0644" mode: "0644"
- name: Enable and start backup timer - name: Enable and start backup timer
ansible.builtin.systemd: ansible.builtin.systemd:
name: restic-backup.timer name: restic-backup.timer
enabled: yes enabled: yes