From 6376bbf2fb445a785cadb08a6f24d73ff4826ed6 Mon Sep 17 00:00:00 2001 From: Frank Dornheim <524257+conloos@users.noreply.github.com> Date: Tue, 14 Mar 2023 06:40:04 +0100 Subject: [PATCH] Removed: borgmatic_initialization_repo --- tasks/03_create_key.yml | 20 +------------------- tasks/06_init_borg_repo.yml | 9 --------- tasks/noauto_create_timer.yml | 17 +++++++++++------ 3 files changed, 12 insertions(+), 34 deletions(-) delete mode 100644 tasks/06_init_borg_repo.yml diff --git a/tasks/03_create_key.yml b/tasks/03_create_key.yml index afefd01..b8890c5 100644 --- a/tasks/03_create_key.yml +++ b/tasks/03_create_key.yml @@ -1,7 +1,5 @@ --- # In this Play an ssh key pair is created for login to the backup server and secure data transfer. -# If you select: "borgmatic_initialization_repo: true", -# the key will automaticly be added to the authorized_keys on the target system. # We do not want the possibly existing key to be used/distributed, # so a backup-specific (backup/backup.pub) one is created. - name: Create ssh-key (if neeeded) for {{ borgbackup_user }} @@ -36,23 +34,7 @@ src: "{{ backup_user_info.home }}/.ssh/backup.pub" register: backup_local_ssh_key - - name: Set authorized key taken from file - when: - - borgmatic_initialization_repo is defined and borgmatic_initialization_repo - ansible.posix.authorized_key: - # example: - # borg_repository: m5vz9gp4@m5vz9gp4.repo.borgbase.com:repo - # have three parts: "username"@"FQDN":"path/to/store/backup", specific: - # a) user: m5vz9gp4 - # b) fqdn: m5vz9gp4.repo.borgbase.co - # c) dir: repo - user: "{{ borg_repository | regex_search('(.*)@', '\\1') | first }}" # part a) - state: present - key: "{{ backup_local_ssh_key['content'] | b64decode }}" - delegate_to: "{{ borg_repository | regex_search('@(.*):', '\\1') | first }}" # part b) - - - name: Print key if the borgmatic_initialization_repo is false - when: borgmatic_initialization_repo is not defined or not borgmatic_initialization_repo + - name: Print key ansible.builtin.debug: msg: "The generated key is: {{ backup_local_ssh_key['content'] | b64decode }}" ... diff --git a/tasks/06_init_borg_repo.yml b/tasks/06_init_borg_repo.yml deleted file mode 100644 index 2d45dd0..0000000 --- a/tasks/06_init_borg_repo.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Init repository - when: - - borgmatic_initialization_repo is defined and borgmatic_initialization_repo - tags: - - install_backup - ansible.builtin.command: - cmd: "su - {{ borgbackup_user }} -c '/usr/local/bin/borgmatic rcreate --encryption keyfile --append-only'" -... diff --git a/tasks/noauto_create_timer.yml b/tasks/noauto_create_timer.yml index b109bbc..ea406e8 100644 --- a/tasks/noauto_create_timer.yml +++ b/tasks/noauto_create_timer.yml @@ -20,11 +20,11 @@ - name: Populate service facts ansible.builtin.service_facts: - - name: Restart borgmatic services + - name: Stop borgmatic services ansible.builtin.systemd: name: "{{ item }}" - state: started - enabled: true + state: stopped + enabled: false masked: false daemon_reload: true when: "item in services" @@ -32,12 +32,17 @@ - backup.service # bug: Need own section without masked else the timer are skipped - - name: Restart borgmatic timers + - name: Stop borgmatic timers ansible.builtin.systemd: name: "{{ item }}" - state: started - enabled: true + state: stopped + enabled: false daemon_reload: true with_items: - "backup.timer" + + - name: Show hints + when: "'backup_init_repo' not in ansible_run_tags" + ansible.builtin.debug: + msg: "Attention: Since the repo was not initialized automatically, the systemd service (backup.service) and the timer (backup.timer) are not activated." ...