Merge branch 'devel' of git://github.com/leafnode/ansible into devel

Conflicts:
	library/packaging/apt_key
reviewable/pr18780/r1
Michael DeHaan 11 years ago
commit 8964b2e049

@ -58,6 +58,11 @@ options:
default: none default: none
description: description:
- url to retrieve key from. - url to retrieve key from.
keyserver:
required: false
default: none
description:
- keyserver to retrieve key from.
state: state:
required: false required: false
choices: [ absent, present ] choices: [ absent, present ]
@ -145,6 +150,10 @@ def download_key(module, url):
except Exception: except Exception:
module.fail_json(msg="error getting key id from url", traceback=format_exc()) module.fail_json(msg="error getting key id from url", traceback=format_exc())
def import_key(module, keyserver, key_id):
cmd = "apt-key adv --keyserver %s --recv %s" % (keyserver, key_id)
(rc, out, err) = module.run_command(cmd, check_rc=True)
return True
def add_key(module, keyfile, keyring, data=None): def add_key(module, keyfile, keyring, data=None):
if data is not None: if data is not None:
@ -179,8 +188,9 @@ def main():
file=dict(required=False), file=dict(required=False),
key=dict(required=False), key=dict(required=False),
keyring=dict(required=False), keyring=dict(required=False),
state=dict(required=False, choices=['present', 'absent'], default='present'),
validate_certs=dict(default='yes', type='bool'), validate_certs=dict(default='yes', type='bool'),
keyserver=dict(required=False),
state=dict(required=False, choices=['present', 'absent'], default='present')
), ),
supports_check_mode=True supports_check_mode=True
) )
@ -191,6 +201,7 @@ def main():
filename = module.params['file'] filename = module.params['file']
keyring = module.params['keyring'] keyring = module.params['keyring']
state = module.params['state'] state = module.params['state']
keyserver = module.params['keyserver']
changed = False changed = False
if key_id: if key_id:
@ -211,7 +222,7 @@ def main():
if key_id and key_id in keys: if key_id and key_id in keys:
module.exit_json(changed=False) module.exit_json(changed=False)
else: else:
if not filename and not data: if not filename and not data and not keyserver:
data = download_key(module, url) data = download_key(module, url)
if key_id and key_id in keys: if key_id and key_id in keys:
module.exit_json(changed=False) module.exit_json(changed=False)
@ -220,6 +231,8 @@ def main():
module.exit_json(changed=True) module.exit_json(changed=True)
if filename: if filename:
add_key(module, filename, keyring) add_key(module, filename, keyring)
elif keyserver:
import_key(module, keyserver, key_id)
else: else:
add_key(module, "-", keyring, data) add_key(module, "-", keyring, data)
changed=False changed=False

Loading…
Cancel
Save