59 lines
1.2 KiB
YAML
59 lines
1.2 KiB
YAML
---
|
|
# tasks file for borgmatic
|
|
- 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 }}"
|
|
|
|
- name: Install borg and borgmatic
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: present
|
|
with_items:
|
|
- borgbackup
|
|
- borgmatic
|
|
|
|
- name: Make dir for borgmatic in etc
|
|
file:
|
|
path: "/etc/borgmatic"
|
|
state: directory
|
|
|
|
- name: Borgmatic config
|
|
template:
|
|
src: borgmatic.config.yaml.j2
|
|
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
|
|
mode: 644
|
|
|
|
- name: Check borgmatic config
|
|
command:
|
|
cmd: validate-borgmatic-config
|
|
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
|
|
dest: /etc/systemd/system/borgmatic.service
|
|
mode: 644
|
|
notify: reload systemd
|
|
|
|
- name: copy systemd timer
|
|
copy:
|
|
src: borgmatic.timer
|
|
dest: /etc/systemd/system/borgmatic.timer
|
|
notify: "reload systemd"
|
|
|
|
- name: enable timer
|
|
systemd:
|
|
name: borgmatic
|
|
enabled: yes
|