Fixes #5750 Fail on missing ~/.ssh and ignore accept_hostkey if stricthoskeychecking is off
This commit is contained in:
parent
1584d8f01b
commit
3ec043ec17
2 changed files with 11 additions and 2 deletions
|
@ -59,6 +59,10 @@ def add_host_key(module, fqdn, key_type="rsa"):
|
||||||
|
|
||||||
result = False
|
result = False
|
||||||
keyscan_cmd = module.get_bin_path('ssh-keyscan', True)
|
keyscan_cmd = module.get_bin_path('ssh-keyscan', True)
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.expanduser("~/.ssh/")):
|
||||||
|
module.fail_json(msg="%s does not exist" % os.path.expanduser("~/.ssh/"))
|
||||||
|
|
||||||
this_cmd = "%s -t %s %s >> ~/.ssh/known_hosts" % (keyscan_cmd, key_type, fqdn)
|
this_cmd = "%s -t %s %s >> ~/.ssh/known_hosts" % (keyscan_cmd, key_type, fqdn)
|
||||||
rc, out, err = module.run_command(this_cmd)
|
rc, out, err = module.run_command(this_cmd)
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ options:
|
||||||
version_added: "1.5"
|
version_added: "1.5"
|
||||||
description:
|
description:
|
||||||
- Add the hostkey for the repo url if not already added.
|
- Add the hostkey for the repo url if not already added.
|
||||||
|
If ssh_args contains "-o StrictHostKeyChecking=no", this
|
||||||
|
parameter is ignored.
|
||||||
ssh_opts:
|
ssh_opts:
|
||||||
required: false
|
required: false
|
||||||
default: None
|
default: None
|
||||||
|
@ -445,8 +447,11 @@ def main():
|
||||||
set_git_ssh(ssh_wrapper, key_file, ssh_opts)
|
set_git_ssh(ssh_wrapper, key_file, ssh_opts)
|
||||||
|
|
||||||
# add the git repo's hostkey
|
# add the git repo's hostkey
|
||||||
#if module.params['accept_hostkey']:
|
if module.params['ssh_opts'] is not None:
|
||||||
add_git_host_key(module, repo, accept_hostkey=module.params['accept_hostkey'])
|
if not "-o StrictHostKeyChecking=no" in module.params['ssh_opts']:
|
||||||
|
add_git_host_key(module, repo, accept_hostkey=module.params['accept_hostkey'])
|
||||||
|
else:
|
||||||
|
add_git_host_key(module, repo, accept_hostkey=module.params['accept_hostkey'])
|
||||||
|
|
||||||
if bare:
|
if bare:
|
||||||
gitconfig = os.path.join(dest, 'config')
|
gitconfig = os.path.join(dest, 'config')
|
||||||
|
|
Loading…
Reference in a new issue