refactor main task individual blocks
This commit is contained in:
1 parent
1d415bfae8
commit
06a7489032
1 file changed
+15
-8
@@ -1,19 +1,20 @@
|
|||||||
---
|
---
|
||||||
- name: Install restic
|
- name: Install and initialize restic
|
||||||
ansible.builtin.apt:
|
become: true
|
||||||
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
|
||||||
command: restic cat config
|
ansible.builtin.command: restic cat config
|
||||||
register: restic_check
|
register: restic_check
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
@@ -22,6 +23,9 @@
|
|||||||
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
|
||||||
|
become: true
|
||||||
|
block:
|
||||||
- name: Deploy restic environment file
|
- name: Deploy restic environment file
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: restic-backup.env.j2
|
src: restic-backup.env.j2
|
||||||
@@ -38,6 +42,9 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0700" ## only root can execute the script
|
mode: "0700" ## only root can execute the script
|
||||||
|
|
||||||
|
- name: Schedule restic backups
|
||||||
|
become: true
|
||||||
|
block:
|
||||||
- name: Deploy restic systemd service
|
- name: Deploy restic systemd service
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: restic-backup.service.j2
|
src: restic-backup.service.j2
|
||||||
|
|||||||
Reference in new issue
Block a user