2023-04-08 23:02:47 +02:00
|
|
|
---
|
2023-04-08 23:08:58 +02:00
|
|
|
- name: "Borg | Copy borgmatic configuration"
|
2023-04-08 23:02:47 +02:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: config.yaml.j2
|
|
|
|
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
|
|
|
|
mode: "0600"
|
|
|
|
|
2023-04-09 09:25:16 +02:00
|
|
|
- name: "Borg | Install borgmatic bach completions"
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "borgmatic --bash-completion > /usr/share/bash-completion/completions/borgmatic"
|
|
|
|
creates: /usr/share/bash-completion/completions/borgmatic
|
|
|
|
|
2023-04-08 23:08:58 +02:00
|
|
|
- name: "Borg | Add borgmatic cron job"
|
2023-04-08 23:02:47 +02:00
|
|
|
ansible.builtin.cron:
|
|
|
|
name: "{{ borgmatic_timer_cron_name }}"
|
|
|
|
hour: "{{ borgmatic_timer_hour }}"
|
|
|
|
minute: "{{ borgmatic_timer_minute }}"
|
|
|
|
user: "{{ borg_user }}"
|
|
|
|
cron_file: "{{ borgmatic_timer_cron_name }}"
|
2023-04-09 09:27:58 +02:00
|
|
|
job: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} >/dev/null"
|
2023-04-08 23:02:47 +02:00
|
|
|
|
2023-04-08 23:08:58 +02:00
|
|
|
- name: "Borg | Init borg repository"
|
2023-04-08 23:02:47 +02:00
|
|
|
ansible.builtin.expect:
|
|
|
|
command: "borgmatic init -e {{ borg_repo_key }}"
|
|
|
|
responses:
|
|
|
|
^.*want to continue connecting.*$: "yes"
|
|
|
|
|
2023-04-08 23:20:21 +02:00
|
|
|
- name: "Borg | Create key export directory"
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ borg_key_export_path }}"
|
|
|
|
state: directory
|
|
|
|
mode: "0750"
|
2023-04-08 23:02:47 +02:00
|
|
|
|
2023-04-08 23:08:58 +02:00
|
|
|
- name: "Borg | Export repo key"
|
2023-04-08 23:02:47 +02:00
|
|
|
ansible.builtin.command:
|
2023-04-09 09:25:16 +02:00
|
|
|
cmd: "borg key export {{ item.path }} {{ item.label }}"
|
2023-04-08 23:02:47 +02:00
|
|
|
loop: "{{ borg_repository }}"
|
2023-04-08 23:08:58 +02:00
|
|
|
|
|
|
|
- name: "Borg | Save repo key to localhost"
|
2023-04-08 23:44:07 +02:00
|
|
|
ansible.posix.synchronize:
|
|
|
|
mode: pull
|
|
|
|
src: "{{ borg_key_export_path }}"
|
2023-04-08 23:20:21 +02:00
|
|
|
dest: "~/"
|