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
This commit is contained in:
parent
bfb43ed0b1
commit
0d9afa84d5
1 changed files with 3 additions and 0 deletions
|
@ -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…
Reference in a new issue