infrastructure/ansible/roles/s3_sync/tasks/main.yml
Jake Howard 06b9197c5b
All checks were successful
/ terraform (push) Successful in 31s
/ ansible (push) Successful in 1m47s
Sync terraform state to restic
This allows it to be backed up easily
2024-01-09 19:56:06 +00:00

53 lines
1.1 KiB
YAML

- name: Include vault
include_vars: vault.yml
- name: Install rclone
package:
name: rclone
become: true
- name: Install runitor
kewlfft.aur.aur:
name: runitor-bin
become: true
- name: Make user
user:
name: rclone
shell: /bin/nologin
system: false
register: rclone_user
become: true
- name: Create config directory
file:
path: "{{ rclone_user.home }}/.config/rclone"
state: directory
owner: rclone
mode: "0700"
become: true
- name: Install rclone config
template:
src: files/rclone.conf
dest: "{{ rclone_user.home }}/.config/rclone/rclone.conf"
owner: rclone
mode: "0600"
become: true
- name: Create config directory
file:
path: "{{ rclone_user.home }}/sync"
state: directory
owner: rclone
mode: "0700"
become: true
- name: Schedule sync
cron:
name: Sync terraform state
hour: 23
minute: 0
job: CHECK_UUID={{ vault_healthchecks_id }} /usr/bin/runitor -- /usr/bin/rclone sync s3:0rng-terraform {{ rclone_user.home }}/sync/0rng-terraform
user: rclone
become: true