apt_key - correct error message about the failure to import a 'gpg' (#74476)
This commit is contained in:
parent
b765d3799b
commit
6ea81b84ed
4 changed files with 12 additions and 2 deletions
2
changelogs/fragments/74476-apt_key-gpg-inline-data.yaml
Normal file
2
changelogs/fragments/74476-apt_key-gpg-inline-data.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- The error message about the failure to import a ```gpg`` key by the ``apt_key`` module was incorrect (https://github.com/ansible/ansible/issues/74423).
|
|
@ -293,7 +293,7 @@ def get_key_id_from_file(module, filename, data=None):
|
||||||
|
|
||||||
(rc, out, err) = module.run_command(cmd, environ_update=lang_env, data=(native_data if is_armored else data), binary_data=not is_armored)
|
(rc, out, err) = module.run_command(cmd, environ_update=lang_env, data=(native_data if is_armored else data), binary_data=not is_armored)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
module.fail_json(msg="Unable to extract key from '%s'" % ('inline data' if data is None else filename), stdout=out, stderr=err)
|
module.fail_json(msg="Unable to extract key from '%s'" % ('inline data' if data is not None else filename), stdout=out, stderr=err)
|
||||||
|
|
||||||
keys = parse_output_for_keys(out)
|
keys = parse_output_for_keys(out)
|
||||||
# assume we only want first key?
|
# assume we only want first key?
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: "Ensure import of a deliberately corrupted downloaded GnuPG binary key results in an 'inline data' occurence in the message"
|
||||||
|
apt_key:
|
||||||
|
url: https://ansible-ci-files.s3.us-east-1.amazonaws.com/test/integration/targets/apt_key/apt-key-corrupt-zeros-2k.gpg
|
||||||
|
register: gpg_inline_result
|
||||||
|
failed_when: "not ('inline data' in gpg_inline_result.msg)"
|
|
@ -26,7 +26,10 @@
|
||||||
|
|
||||||
- import_tasks: 'apt_key.yml'
|
- import_tasks: 'apt_key.yml'
|
||||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
when: ansible_distribution in ('Ubuntu', 'Debian')
|
||||||
|
|
||||||
|
- import_tasks: 'apt_key_inline_data.yml'
|
||||||
|
when: ansible_distribution in ('Ubuntu', 'Debian')
|
||||||
|
|
||||||
- import_tasks: 'file.yml'
|
- import_tasks: 'file.yml'
|
||||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
when: ansible_distribution in ('Ubuntu', 'Debian')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue