50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
---
|
|
- name: Ensure /etc/borgmatic exists
|
|
ansible.builtin.file:
|
|
path: /etc/borgmatic
|
|
state: directory
|
|
mode: "0700"
|
|
owner: "{{ borg_user }}"
|
|
group: "{{ borg_group }}"
|
|
|
|
- name: "Borg | Copy borgmatic configuration"
|
|
ansible.builtin.template:
|
|
src: config.yaml.j2
|
|
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
|
|
mode: "0600"
|
|
|
|
- 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
|
|
|
|
- name: "Borg | Init borg repository"
|
|
ansible.builtin.expect:
|
|
command: "borgmatic init -e {{ borg_repo_key }} {{ borgmatic_init_options | default([]) }}"
|
|
responses:
|
|
^.*want to continue connecting.*$: "yes"
|
|
|
|
- name: "Borg | Create key export directory"
|
|
ansible.builtin.file:
|
|
path: "{{ borg_key_export_path }}"
|
|
state: directory
|
|
mode: "0750"
|
|
|
|
- name: "Borg | Export repo key"
|
|
ansible.builtin.command:
|
|
cmd: "borg key export {{ item.path }} {{ item.label }}_{{ inventory_hostname }}"
|
|
chdir: "{{ borg_key_export_path }}"
|
|
loop: "{{ borg_repository }}"
|
|
ignore_errors: true
|
|
|
|
- name: "Borg | Export repo key"
|
|
ansible.builtin.command:
|
|
cmd: "borg key export ssh://{{ borgbase_repo.repo_id }}@{{ borgbackup_ssh_host }}/./repo borgbase"
|
|
chdir: "{{ borg_key_export_path }}"
|
|
when: borgbase is defined and borgbase
|
|
|
|
- name: "Borg | Save repo key to localhost"
|
|
ansible.posix.synchronize:
|
|
mode: pull
|
|
src: "{{ borg_key_export_path }}"
|
|
dest: "~/"
|