WIP: Export repo key

This commit is contained in:
phil 2023-04-08 23:08:58 +02:00
parent 00f0b60613
commit 3dd71eac1d
2 changed files with 15 additions and 9 deletions

View file

@ -1,11 +1,11 @@
--- ---
- name: "Borgamtic | Copy configuration" - name: "Borg | Copy borgmatic configuration"
ansible.builtin.template: ansible.builtin.template:
src: config.yaml.j2 src: config.yaml.j2
dest: "/etc/borgmatic/{{ borgmatic_config_name }}" dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
mode: "0600" mode: "0600"
- name: "Borgmatic | Add cron job" - name: "Borg | Add borgmatic cron job"
ansible.builtin.cron: ansible.builtin.cron:
name: "{{ borgmatic_timer_cron_name }}" name: "{{ borgmatic_timer_cron_name }}"
hour: "{{ borgmatic_timer_hour }}" hour: "{{ borgmatic_timer_hour }}"
@ -14,18 +14,24 @@
cron_file: "{{ borgmatic_timer_cron_name }}" cron_file: "{{ borgmatic_timer_cron_name }}"
job: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}" job: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
- name: "Borgmatic | Init borg repository" - name: "Borg | Init borg repository"
ansible.builtin.expect: ansible.builtin.expect:
command: "borgmatic init -e {{ borg_repo_key }}" command: "borgmatic init -e {{ borg_repo_key }}"
responses: responses:
^.*want to continue connecting.*$: "yes" ^.*want to continue connecting.*$: "yes"
- name: "Borgmatic | Create backup" - name: "Borg | Create backup"
ansible.builtin.command: ansible.builtin.command:
cmd: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}" cmd: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
- name: "Borgmatic | Export repo key" - name: "Borg | Export repo key"
ansible.builtin.command: ansible.builtin.command:
cmd: "borg key export {{ item }} > {{ borg_key_export_path }}" cmd: "borg key export {{ item }}"
loop: "{{ borg_repository }}" loop: "{{ borg_repository }}"
register: repo_key_export
- name: "Borg | Save repo key to localhost"
ansible.builtin.copy:
content: "{{ repo_key_export.stdout }}"
dest: "{{ borg_key_export_path }}"
delegate_to: localhost delegate_to: localhost

View file

@ -12,6 +12,6 @@
when: borgbase is defined and borgbase when: borgbase is defined and borgbase
tags: borgbase tags: borgbase
- name: Setup borgmatic - name: Setup borg
ansible.builtin.import_tasks: borgmatic.yml ansible.builtin.import_tasks: borg.yml
tags: borgmatic tags: borg