Skip to content

Commit

Permalink
Merge pull request #1587 from grycap/devel
Browse files Browse the repository at this point in the history
Fix error with bastion hosts
  • Loading branch information
micafer authored Jul 3, 2024
2 parents d6e586e + 84ad8a6 commit cde5e88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions IM/ConfManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1387,18 +1387,20 @@ def configure_ansible(self, ssh, tmp_dir, ansible_version=None):
f.write(ssh.proxy_host.private_key)
os.chmod(priv_key_filename, 0o600)

ssh_options = "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"

proxy_command = "ssh -W %%h:%%p -i %s -p %d %s %s@%s" % (priv_key_filename,
ssh.proxy_host.port,
"-o StrictHostKeyChecking=no",
ssh_options,
ssh.proxy_host.username,
ssh.proxy_host.host)
else:
proxy_command = "sshpass -p %s ssh -W %%h:%%p -p %d %s %s@%s" % (ssh.proxy_host.password,
ssh.proxy_host.port,
"-o StrictHostKeyChecking=no",
ssh_options,
ssh.proxy_host.username,
ssh.proxy_host.host)
ssh_args = "ansible_ssh_extra_args=\" -oProxyCommand='%s'\"" % proxy_command
ssh_args = "ansible_ssh_extra_args=\"%s -oProxyCommand='%s'\"" % (ssh_options, proxy_command)
inv_out.write("%s ansible_port=%d ansible_ssh_port=%d %s" % (ssh.host, ssh.port,
ssh.port, ssh_args))

Expand Down
8 changes: 5 additions & 3 deletions IM/CtxtAgentBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,20 @@ def add_proxy_host_line(self, vm_data):
f.write(proxy['private_key'])
os.chmod(priv_key_filename, 0o600)

ssh_options = "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"

cmd = "ssh -W %%h:%%p -i %s -p %d %s %s@%s" % (priv_key_filename,
proxy['port'],
"-o StrictHostKeyChecking=no",
ssh_options,
proxy['user'],
proxy['host'])
else:
cmd = "sshpass -p %s ssh -W %%h:%%p -p %d %s %s@%s" % (proxy['password'],
proxy['port'],
"-o StrictHostKeyChecking=no",
ssh_options,
proxy['user'],
proxy['host'])
proxy_command = "ansible_ssh_extra_args=\" -oProxyCommand='%s'\"" % cmd
proxy_command = "ansible_ssh_extra_args=\"%s -oProxyCommand='%s'\"" % (ssh_options, cmd)

with open(filename) as f:
inventoy_data = ""
Expand Down

0 comments on commit cde5e88

Please sign in to comment.