known_hosts: return rc and stderr in fail_json (#85871)

* When ssh-keygen fails, return rc and stderr in fail_json
  in order to help debugging.

Fixes: #85850

Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
pull/85545/head
Abhijeet Kasurde 2 months ago committed by GitHub
parent c3f87b31d1
commit 6bee84318d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,3 @@
---
minor_changes:
- known_hosts - return rc and stderr when ssh-keygen command fails for further debugging (https://github.com/ansible/ansible/issues/85850).

@ -225,7 +225,13 @@ def sanity_check(module, host, key, sshkeygen):
rc, stdout, stderr = module.run_command(sshkeygen_command)
if stdout == '': # host not found
module.fail_json(msg="Host parameter does not match hashed host field in supplied key")
results = {
"msg": "Host parameter does not match hashed host field in supplied key",
"rc": rc,
}
if stderr:
results["stderr"] = stderr
module.fail_json(**results)
def search_for_host_key(module, host, key, path, sshkeygen):

@ -507,3 +507,4 @@
that:
- result is failed
- result.msg == 'Host parameter does not match hashed host field in supplied key'
- result.rc is defined

Loading…
Cancel
Save