2022-03-04 14:24:09 +00:00
|
|
|
---
|
|
|
|
# tasks file for borgmatic
|
2022-03-09 09:46:21 +00:00
|
|
|
- name: debug
|
|
|
|
debug:
|
|
|
|
msg: "{{ borgmatic_config_file }}"
|
|
|
|
|
2022-03-08 13:42:14 +00:00
|
|
|
- name: stat on sources
|
|
|
|
stat:
|
|
|
|
path: "{{ item }}"
|
|
|
|
with_items: "{{ borg_source_directories }}"
|
|
|
|
register: sources_exists
|
|
|
|
|
|
|
|
- name: Assert sources exists
|
|
|
|
assert:
|
|
|
|
that: "{{ item }}.stat.exists"
|
|
|
|
with_items: "{{ sources_exists.results }}"
|
|
|
|
|
2022-03-04 14:24:09 +00:00
|
|
|
- name: Install borg and borgmatic
|
|
|
|
apt:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items:
|
2022-03-08 13:42:14 +00:00
|
|
|
- borgbackup
|
2022-03-04 14:24:09 +00:00
|
|
|
- borgmatic
|
2022-03-08 13:42:14 +00:00
|
|
|
|
|
|
|
- name: Make dir for borgmatic in etc
|
|
|
|
file:
|
|
|
|
path: "/etc/borgmatic"
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Borgmatic config
|
|
|
|
template:
|
|
|
|
src: borgmatic.config.yaml.j2
|
2022-03-09 09:46:21 +00:00
|
|
|
dest: "{{ borgmatic_config_file }}"
|
2022-03-08 13:42:14 +00:00
|
|
|
mode: 644
|
|
|
|
|
|
|
|
- name: Check borgmatic config
|
|
|
|
command:
|
2022-03-09 09:46:21 +00:00
|
|
|
cmd: "validate-borgmatic-config -c {{ borgmatic_config_file}}"
|
2022-03-08 13:42:14 +00:00
|
|
|
register: validate_borgmatic_config
|
|
|
|
|
|
|
|
- name: Assert that config is validate
|
|
|
|
assert:
|
|
|
|
that: validate_borgmatic_config.failed != true
|
|
|
|
|
|
|
|
- name: copy systemd service
|
|
|
|
template:
|
|
|
|
src: borgmatic.service.j2
|
2022-03-09 09:46:21 +00:00
|
|
|
dest: "/lib/systemd/system/borgmatic_{{ borgmatic_name }}.service"
|
2022-03-08 13:42:14 +00:00
|
|
|
mode: 644
|
|
|
|
notify: reload systemd
|
|
|
|
|
2022-03-09 09:46:21 +00:00
|
|
|
- name: copy systemd timer for executing borgmatic after boot
|
|
|
|
template:
|
|
|
|
src: borgmatic.afterboot.timer.j2
|
|
|
|
dest: "/lib/systemd/system/borgmatic_{{ borgmatic_name }}.timer"
|
2022-03-08 13:42:14 +00:00
|
|
|
notify: "reload systemd"
|
|
|
|
|
|
|
|
- name: enable timer
|
|
|
|
systemd:
|
2022-03-09 09:46:21 +00:00
|
|
|
name: "borgmatic_{{ borgmatic_name }}"
|
2022-03-08 13:42:14 +00:00
|
|
|
enabled: yes
|