Commit c15cffab by Rob Smith

This fixes bugs added as a part of 8665b063

1. if accept_hostkey is false, no matter if the host key is known or not, it will fail.

2. We don't check for the host key in /etc/ssh/ssh_known_hosts

This fixes both of those issues.
parent 3719f3f4
...@@ -6,7 +6,8 @@ def add_git_host_key(module, url, accept_hostkey=True): ...@@ -6,7 +6,8 @@ def add_git_host_key(module, url, accept_hostkey=True):
if fqdn: if fqdn:
known_host = check_hostkey(module, fqdn) known_host = check_hostkey(module, fqdn)
if not known_host and accept_hostkey: if not known_host:
if accept_hostkey:
rc, out, err = add_host_key(module, fqdn) rc, out, err = add_host_key(module, fqdn)
if rc != 0: if rc != 0:
module.fail_json(msg="failed to add %s hostkey: %s" % (fqdn, out + err)) module.fail_json(msg="failed to add %s hostkey: %s" % (fqdn, out + err))
...@@ -42,6 +43,14 @@ def check_hostkey(module, fqdn): ...@@ -42,6 +43,14 @@ def check_hostkey(module, fqdn):
if rc == 0: if rc == 0:
if out != "": if out != "":
result = True result = True
else:
# Check the main system location
this_cmd = keygen_cmd + " -H -f /etc/ssh/ssh_known_hosts -F " + fqdn
rc, out, err = module.run_command(this_cmd)
if rc == 0:
if out != "":
result = True
return result return result
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment