Set accept_hostkey to False by default in the git module and fail

early if the key is unknown
This commit is contained in:
James Tanner 2014-01-11 11:02:01 -05:00
commit eeee1e1c5a
2 changed files with 13 additions and 13 deletions

View file

@ -2,16 +2,16 @@ def add_git_host_key(module, url, accept_hostkey=True):
""" idempotently add a git url hostkey """
if accept_hostkey:
fqdn = get_fqdn(module.params['repo'])
fqdn = get_fqdn(module.params['repo'])
if fqdn:
known_host = check_hostkey(module, fqdn)
if not known_host:
rc, out, err = add_host_key(module, fqdn)
if rc != 0:
module.fail_json(msg="failed to add %s hostkey: %s" % (fqdn, out + err))
if fqdn:
known_host = check_hostkey(module, fqdn)
if not known_host and accept_hostkey:
rc, out, err = add_host_key(module, fqdn)
if rc != 0:
module.fail_json(msg="failed to add %s hostkey: %s" % (fqdn, out + err))
else:
module.fail_json(msg="%s has an unknown hostkey. Set accept_hostkey to True or manually add the hostkey prior to running the git module" % fqdn)
def get_fqdn(repo_url):