apt-key: convert ids to the 'short' format
Fixes: $ ansible all -m apt_key -a 'state=present id=7A82B743B9B8E46F12C733FA4759FA960E27C0A6 keyserver=hkp://keyserver.ubuntu.com:80' --sudo 127.0.0.1 | SUCCESS => { "changed": true } $ ansible all -m apt_key -a 'state=absent id=7A82B743B9B8E46F12C733FA4759FA960E27C0A6' --sudo 127.0.0.1 | SUCCESS => { "changed": false } $ apt-key export 7A82B743B9B8E46F12C733FA4759FA960E27C0A6 -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1 ... See https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1481871
This commit is contained in:
parent
7d09792758
commit
8f23e54a80
1 changed files with 6 additions and 3 deletions
|
@ -220,19 +220,22 @@ def main():
|
||||||
keyserver = module.params['keyserver']
|
keyserver = module.params['keyserver']
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
|
# we use the "short" id: key_id[-8:], short_format=True
|
||||||
|
# it's a workaround for https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1481871
|
||||||
|
|
||||||
if key_id:
|
if key_id:
|
||||||
try:
|
try:
|
||||||
_ = int(key_id, 16)
|
_ = int(key_id, 16)
|
||||||
if key_id.startswith('0x'):
|
if key_id.startswith('0x'):
|
||||||
key_id = key_id[2:]
|
key_id = key_id[2:]
|
||||||
key_id = key_id.upper()
|
key_id = key_id.upper()[-8:]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
module.fail_json(msg="Invalid key_id", id=key_id)
|
module.fail_json(msg="Invalid key_id", id=key_id)
|
||||||
|
|
||||||
# FIXME: I think we have a common facility for this, if not, want
|
# FIXME: I think we have a common facility for this, if not, want
|
||||||
check_missing_binaries(module)
|
check_missing_binaries(module)
|
||||||
|
|
||||||
short_format = (key_id is not None and len(key_id) == 8)
|
short_format = True
|
||||||
keys = all_keys(module, keyring, short_format)
|
keys = all_keys(module, keyring, short_format)
|
||||||
return_values = {}
|
return_values = {}
|
||||||
|
|
||||||
|
@ -257,7 +260,7 @@ def main():
|
||||||
keys2 = all_keys(module, keyring, short_format)
|
keys2 = all_keys(module, keyring, short_format)
|
||||||
if len(keys) != len(keys2):
|
if len(keys) != len(keys2):
|
||||||
changed=True
|
changed=True
|
||||||
if key_id and not key_id[-16:] in keys2:
|
if key_id and not key_id in keys2:
|
||||||
module.fail_json(msg="key does not seem to have been added", id=key_id)
|
module.fail_json(msg="key does not seem to have been added", id=key_id)
|
||||||
module.exit_json(changed=changed)
|
module.exit_json(changed=changed)
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
|
|
Loading…
Reference in a new issue