diff --git a/roles/backup_client/tasks/main.yml b/roles/backup_client/tasks/main.yml index c09f302722240da8b39868b7f2fe68bce8bd935d..dcbcd1d0581ee168fb8a8100d5c47715326d0f23 100644 --- a/roles/backup_client/tasks/main.yml +++ b/roles/backup_client/tasks/main.yml @@ -1,14 +1,14 @@ --- - name: Install backup software - apt: + ansible.builtin.apt: name: - duplicity - duply state: present - name: Set-up Duply directories - file: + ansible.builtin.file: path: "{{ item }}" state: directory owner: root @@ -24,7 +24,7 @@ - "/var/cache/duply/main" - name: Deploy GnuPG private keys - copy: + ansible.builtin.copy: content: "{{ backup_encryption_key }}" dest: "/etc/duply/main/private_keys.asc" owner: root @@ -37,7 +37,7 @@ - Import public keys - name: Deploy GnuPG public keys - copy: + ansible.builtin.copy: content: "{{ backup_additional_encryption_keys | join('\n') }}" dest: "/etc/duply/main/public_keys.asc" owner: root @@ -50,7 +50,7 @@ - Import public keys - name: Extract encryption key identifier (Duplicty requires key ID in hexadecimal format) - shell: "set -o pipefail && gpg --no-tty --list-packets /etc/duply/main/private_keys.asc | grep keyid: | + ansible.builtin.shell: "set -o pipefail && gpg --no-tty --list-packets /etc/duply/main/private_keys.asc | grep keyid: | head -n1 | sed -e 's/.*: //'" args: executable: /bin/bash @@ -59,7 +59,7 @@ failed_when: not backup_encryption_key_id.stdout - name: Extract additional encryption keys identifiers (Duplicty requires key ID in hexadecimal format) - shell: "set -o pipefail && gpg --no-tty --list-packets /etc/duply/main/public_keys.asc | grep keyid: | + ansible.builtin.shell: "set -o pipefail && gpg --no-tty --list-packets /etc/duply/main/public_keys.asc | grep keyid: | sed -e 's/.*: //' | sort -u | tr '\n' ',' | sed -e 's/,$//'" args: executable: /bin/bash @@ -69,7 +69,7 @@ failed_when: not backup_additional_encryption_keys_ids.stdout - name: Deploy private SSH key for logging-in into backup server - copy: + ansible.builtin.copy: content: "{{ backup_ssh_key }}" dest: "/etc/duply/main/ssh/identity" owner: root @@ -78,7 +78,7 @@ no_log: true - name: Deploy custom known_hosts for backup purposes - template: + ansible.builtin.template: src: "known_hosts.j2" dest: "/etc/duply/main/ssh/known_hosts" owner: root @@ -86,7 +86,7 @@ mode: "0600" - name: Deploy Duply configuration file - template: + ansible.builtin.template: src: "duply_main_conf.j2" dest: "/etc/duply/main/conf" owner: root @@ -94,7 +94,7 @@ mode: "0600" - name: Deploy base exclude pattern (exclude all by default) - copy: + ansible.builtin.copy: content: "- **" dest: "/etc/duply/main/exclude" owner: root @@ -102,7 +102,7 @@ mode: "0600" - name: Set-up directory for storing pre-backup scripts - file: + ansible.builtin.file: path: "/etc/duply/main/pre.d/" state: directory owner: root @@ -110,7 +110,7 @@ mode: "0700" - name: Set-up script for running all pre-backup scripts - copy: + ansible.builtin.copy: src: "duply_pre" dest: "/etc/duply/main/pre" owner: root @@ -118,7 +118,7 @@ mode: "0700" - name: Deploy crontab entry for running backups - cron: + ansible.builtin.cron: name: backup cron_file: backup hour: "2" @@ -128,7 +128,7 @@ user: root - name: Ensure the file with include patterns exists (but do not overwrite) - copy: + ansible.builtin.copy: content: "" dest: /etc/duply/main/include force: false @@ -137,7 +137,7 @@ mode: "0600" - name: Explicitly run all handlers - include_tasks: ../handlers/main.yml + ansible.builtin.include_tasks: ../handlers/main.yml when: "run_handlers | default(False) | bool()" tags: - handlers