From 3dd71eac1d42588a5581334a232061e1902c2216 Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 8 Apr 2023 23:08:58 +0200 Subject: [PATCH] WIP: Export repo key --- tasks/{borgmatic.yml => borg.yml} | 18 ++++++++++++------ tasks/main.yml | 6 +++--- 2 files changed, 15 insertions(+), 9 deletions(-) rename tasks/{borgmatic.yml => borg.yml} (64%) diff --git a/tasks/borgmatic.yml b/tasks/borg.yml similarity index 64% rename from tasks/borgmatic.yml rename to tasks/borg.yml index b81ca25..9659d0c 100644 --- a/tasks/borgmatic.yml +++ b/tasks/borg.yml @@ -1,11 +1,11 @@ --- -- name: "Borgamtic | Copy configuration" +- name: "Borg | Copy borgmatic configuration" ansible.builtin.template: src: config.yaml.j2 dest: "/etc/borgmatic/{{ borgmatic_config_name }}" mode: "0600" -- name: "Borgmatic | Add cron job" +- name: "Borg | Add borgmatic cron job" ansible.builtin.cron: name: "{{ borgmatic_timer_cron_name }}" hour: "{{ borgmatic_timer_hour }}" @@ -14,18 +14,24 @@ cron_file: "{{ borgmatic_timer_cron_name }}" job: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}" -- name: "Borgmatic | Init borg repository" +- name: "Borg | Init borg repository" ansible.builtin.expect: command: "borgmatic init -e {{ borg_repo_key }}" responses: ^.*want to continue connecting.*$: "yes" -- name: "Borgmatic | Create backup" +- name: "Borg | Create backup" ansible.builtin.command: cmd: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}" -- name: "Borgmatic | Export repo key" +- name: "Borg | Export repo key" ansible.builtin.command: - cmd: "borg key export {{ item }} > {{ borg_key_export_path }}" + cmd: "borg key export {{ item }}" 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 diff --git a/tasks/main.yml b/tasks/main.yml index c0fd931..42df167 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,6 +12,6 @@ when: borgbase is defined and borgbase tags: borgbase -- name: Setup borgmatic - ansible.builtin.import_tasks: borgmatic.yml - tags: borgmatic +- name: Setup borg + ansible.builtin.import_tasks: borg.yml + tags: borg