Add retries to apt_key with keyserver, fixes #3986 (#3987)

Public SKS gpg servers frequently are unavailable, but a retry
can mitigate frequent failures.
pull/18777/head
mattymo 9 years ago committed by Matt Clay
parent 17ebf51bd4
commit 5692d28f93

@ -171,7 +171,14 @@ def import_key(module, keyring, keyserver, key_id):
cmd = "apt-key --keyring %s adv --keyserver %s --recv %s" % (keyring, keyserver, key_id)
else:
cmd = "apt-key adv --keyserver %s --recv %s" % (keyserver, key_id)
(rc, out, err) = module.run_command(cmd, check_rc=True)
for retry in xrange(5):
(rc, out, err) = module.run_command(cmd)
if rc == 0:
break
else:
# Out of retries
module.fail_json(cmd=cmd, msg="error fetching key from keyserver: %s" % keyserver,
rc=rc, stdout=out, stderr=err)
return True
def add_key(module, keyfile, keyring, data=None):

Loading…
Cancel
Save