Files
ansible/tasks/borgmatic.yml
T
Bart Sjerps ee8ca96a7b update
2026-07-20 11:20:51 +02:00

71 lines
1.5 KiB
YAML

---
- name: Install packages
ansible.builtin.package:
name: "borgmatic"
state: present
- name: Create directories
file:
path: '{{ item }}'
state: directory
owner: root
group: root
mode: '0750'
loop:
- '/etc/borgmatic'
- '/etc/borgmatic.d'
- name: Deploy borgmatic config
template:
src: "{{ item.source }}"
dest: "{{ item.target }}"
owner: root
group: root
mode: '0644'
loop:
- { source: "templates/borgmatic-system.yaml", target: "/etc/borgmatic.d/system.yaml" }
- { source: "templates/borgmatic-data.yaml", target: "/etc/borgmatic.d/data.yaml" }
- name: Deploy borgmatic excludes
template:
src: templates/borgmatic-excludes
dest: /etc/borgmatic/excludes
owner: root
group: root
mode: '0644'
- name: SSH Keypair
openssh_keypair:
path: /etc/borgmatic/borg_key
owner: root
group: root
- name: Get SSH key
slurp:
src: /etc/borgmatic/borg_key.pub
register: remote_key
- name: Deploy borgmatic authorized_key
template:
src: templates/borgmatic-auth-key
dest: /etc/borgmatic/authorized_keys
owner: root
group: root
mode: '0644'
vars:
included_content: "{{ remote_key.content | b64decode }}"
- name: Pickup authorized_key
fetch:
src: /etc/borgmatic/authorized_keys
dest: authorized_keys/{{ ansible_hostname }}
flat: yes
- name: Setup Backup Cron Job
ansible.builtin.cron:
name: "borgmatic"
minute: 0
hour: 1
job: /usr/bin/borgmatic