Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06a7489032 | ||
|
|
1d415bfae8 | ||
|
|
39231dce9d | ||
|
|
23cda0168e |
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
# Ansible Collection
|
# Ansible Collection
|
||||||
|
|
||||||
Opinionated set of roles to configure reasonable defaults for newly provisioned virtual machines. The repository provides a ready-to-use Ansible Collection (`studio.ansible`) containing reusable roles.
|
Opinionated set of roles to configure reasonable defaults for newly provisioned virtual machines. The repository provides a ready-to-use Ansible Collection (`studiovitali.ansible`) containing reusable roles.
|
||||||
|
|
||||||
Currently only supports Debian-based systems.
|
Currently only supports Debian-based systems.
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
## galaxy.yml
|
## galaxy.yml
|
||||||
|
|
||||||
namespace: studio
|
namespace: studiovitali
|
||||||
name: ansible
|
name: ansible
|
||||||
readme: README.md
|
readme: README.md
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|||||||
@@ -1,26 +1,31 @@
|
|||||||
---
|
---
|
||||||
- name: Install restic
|
- name: Install and initialize restic
|
||||||
ansible.builtin.apt:
|
become: true
|
||||||
name: restic
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- 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: Check if already initialized
|
- name: Install restic
|
||||||
ansible.builtin.command: restic snapshots
|
ansible.builtin.apt:
|
||||||
|
name: restic
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Check if repository is initialized
|
||||||
|
ansible.builtin.command: restic cat config
|
||||||
register: restic_check
|
register: restic_check
|
||||||
failed_when: false
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
- name: Initialize repository
|
- name: Initialize repository
|
||||||
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
|
||||||
@@ -37,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
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Source environment variables if running manually/outside Systemd
|
## Environment is injected by the systemd unit via EnvironmentFile=/etc/restic-backup.env. Run manually with: systemctl start restic-backup.service
|
||||||
if [ -f /etc/restic-backup.env ]; then
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
. /etc/restic-backup.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Starting Restic Backup at $(date)"
|
echo "Starting Restic Backup at $(date)"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user