diff --git a/roles/backup_client/molecule/default/tests/test_default.py b/roles/backup_client/molecule/default/tests/test_default.py index 7a584c24034d4b6daf4a9a5f80ff27c7b220da4b..dc2a1813e108169c7aa8e11f8faa7a9959c4459d 100644 --- a/roles/backup_client/molecule/default/tests/test_default.py +++ b/roles/backup_client/molecule/default/tests/test_default.py @@ -1,9 +1,10 @@ +import os + import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('all') -testinfra_hosts.remove('backup-server') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory', 'parameters-optional']) def test_installed_packages(host): diff --git a/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py b/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py index 64217717f2fb10d5f26ef671d749fe7a2661e818..fa85b00263efd0a4c90982133cd8b80bd6d1441e 100644 --- a/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py @@ -1,8 +1,10 @@ +import os + import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('parameters-mandatory') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory']) def test_gnupg_private_keys_file_content(host): diff --git a/roles/backup_client/molecule/default/tests/test_parameters_optional.py b/roles/backup_client/molecule/default/tests/test_parameters_optional.py index afa6e847c5c91e184c5e35f12b809ebed94c4403..ce91f3bb8104fb9a43fba73e8f4e43c276df2aa3 100644 --- a/roles/backup_client/molecule/default/tests/test_parameters_optional.py +++ b/roles/backup_client/molecule/default/tests/test_parameters_optional.py @@ -1,8 +1,10 @@ +import os + import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('parameters-optional') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-optional']) def test_gnupg_private_keys_file_content(host): diff --git a/roles/backup_client/tasks/main.yml b/roles/backup_client/tasks/main.yml index 607b70e4500f2a2b56b28c95a3a8418afda9bfcf..a0ec36f18d322ffe13d9c0a2472cafd81d10f522 100644 --- a/roles/backup_client/tasks/main.yml +++ b/roles/backup_client/tasks/main.yml @@ -3,12 +3,12 @@ - name: Install pexpect for pexpect+sftp Duplicity backend (mainly needed on Stretch) apt: name: "python-pexpect" - state: installed + state: present - name: Install backup software apt: name: "{{ item }}" - state: installed + state: present with_items: - duplicity - duply @@ -54,16 +54,18 @@ - Import public keys - name: Extract encryption key identifier (Duplicty requires key ID in hexadecimal format) - shell: "{{ gnupg_binary }} --list-packets /etc/duply/main/private_keys.asc | grep keyid: | head -n1 | sed -e 's/.*: //' | sed -re 's/^.{{ '{' + gnupg_key_cutoff + '}' }}//'" + shell: "{{ gnupg_binary }} --list-packets /etc/duply/main/private_keys.asc | grep keyid: | + head -n1 | sed -e 's/.*: //' | sed -re 's/^.{{ '{' + gnupg_key_cutoff + '}' }}//'" register: backup_encryption_key_id - changed_when: False + changed_when: false failed_when: backup_encryption_key_id.stdout == "" - name: Extract additional encryption keys identifiers (Duplicty requires key ID in hexadecimal format) - shell: "{{ gnupg_binary }} --list-packets /etc/duply/main/public_keys.asc | grep keyid: | sed -e 's/.*: //' | sort -u | sed -re 's/^.{{ '{' + gnupg_key_cutoff + '}' }}//' | tr '\n' ',' | sed -e 's/,$//'" + shell: "{{ gnupg_binary }} --list-packets /etc/duply/main/public_keys.asc | grep keyid: | + sed -e 's/.*: //' | sort -u | sed -re 's/^.{{ '{' + gnupg_key_cutoff + '}' }}//' | tr '\n' ',' | sed -e 's/,$//'" when: backup_additional_encryption_keys register: backup_additional_encryption_keys_ids - changed_when: False + changed_when: false failed_when: backup_additional_encryption_keys_ids.stdout == "" - name: Deploy private SSH key for logging-in into backup server @@ -73,7 +75,7 @@ owner: root group: root mode: 0600 - no_log: True + no_log: true - name: Deploy custom known_hosts for backup purposes template: @@ -129,7 +131,7 @@ copy: content: "" dest: /etc/duply/main/include - force: no + force: false group: root owner: root mode: 0600