From 4e6628e86c0db44109023ef11c8af2629ea0be77 Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 8 Apr 2023 23:20:21 +0200 Subject: [PATCH] Fetch exported keys --- defaults/main.yml | 2 +- tasks/borg.yml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 8caf7b9..057cfc6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,7 +4,7 @@ borg_exclude_patterns: [] borg_one_file_system: true borg_exclude_from: [] borg_encryption_passcommand: false -borg_key_export_path: "~/{{ borg_repository }}.key" +borg_key_export_path: "/root/borg_keys" borg_lock_wait_time: 5 borg_ssh_key_file_path: "/root/.ssh/{{ borg_ssh_key_name }}" borg_ssh_key_name: borgbackup diff --git a/tasks/borg.yml b/tasks/borg.yml index 9659d0c..3975489 100644 --- a/tasks/borg.yml +++ b/tasks/borg.yml @@ -20,18 +20,18 @@ responses: ^.*want to continue connecting.*$: "yes" -- name: "Borg | Create backup" - ansible.builtin.command: - cmd: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}" +- 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 }}" + cmd: "borg key export {{ item }} > {{ borg_key_export_path }}/{{ item }}.key" 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 + ansible.builtin.fetch: + src: "{{ repo_key_export.stdout }}" + dest: "~/"