Files

71 lines
1.5 KiB
YAML
Raw Permalink Normal View History

2026-06-28 16:39:16 +02:00
---
- name: Install packages
ansible.builtin.package:
name: "borgmatic"
state: present
2026-07-10 10:04:17 +02:00
- name: Create directories
file:
path: '{{ item }}'
state: directory
owner: root
group: root
mode: '0750'
loop:
- '/etc/borgmatic'
- '/etc/borgmatic.d'
2026-06-28 16:39:16 +02:00
- name: Deploy borgmatic config
template:
2026-07-20 11:20:51 +02:00
src: "{{ item.source }}"
dest: "{{ item.target }}"
2026-06-28 16:39:16 +02:00
owner: root
group: root
mode: '0644'
2026-07-20 11:20:51 +02:00
loop:
- { source: "templates/borgmatic-system.yaml", target: "/etc/borgmatic.d/system.yaml" }
- { source: "templates/borgmatic-data.yaml", target: "/etc/borgmatic.d/data.yaml" }
2026-06-28 16:39:16 +02:00
- 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
2026-07-20 11:20:51 +02:00
dest: authorized_keys/{{ ansible_hostname }}
2026-06-28 16:39:16 +02:00
flat: yes
- name: Setup Backup Cron Job
ansible.builtin.cron:
name: "borgmatic"
minute: 0
hour: 1
job: /usr/bin/borgmatic