--- # The zeroed hash matches no file, so the key task must be the one that fails. - name: Run the role with a checksum the stand-in key does not have block: - name: Include the role ansible.builtin.include_role: name: mortis.kamino.docker vars: docker_gpg_url: file:///srv/docker-stub-repo/docker.asc docker_repo_base_url: file:///srv/docker-stub-repo docker_keyring_path: /tmp/docker-refused-key.asc docker_keyring_checksum: "{{ '0' * 64 }}" - name: Fail when the wrong key was accepted ansible.builtin.fail: msg: MOLECULE-ACCEPTED rescue: - name: The key download stopped the play ansible.builtin.assert: that: - ansible_failed_task.name == 'Install Docker APT GPG key' - "'did not match' in ansible_failed_result.msg | default('')" quiet: true always: - name: Remove the refused key path ansible.builtin.file: path: /tmp/docker-refused-key.asc state: absent