ssh-keyscan can fail to find keys for a host.

When it does, we need to fail otherwise other code will fail later.

Fixes #18676
pull/18700/head
Toshio Kuratomi 8 years ago
parent bfb43ed0b1
commit 0d9afa84d5

@ -187,6 +187,9 @@ def add_host_key(module, fqdn, key_type="rsa", create_dir=False):
this_cmd = "%s -t %s %s" % (keyscan_cmd, key_type, fqdn)
rc, out, err = module.run_command(this_cmd)
# ssh-keyscan gives a 0 exit code and prints nothins on timeout
if rc != 0 or not out:
module.fail_json(msg='failed to get the hostkey for %s' % fqdn)
module.append_to_file(user_host_file, out)
return rc, out, err

Loading…
Cancel
Save