当将 ping 与 ansible 一起使用时,它会返回“无法执行命令行和远程命令。”
我希望使用Bastian服务器使用ProxyJump,可以使用.ssh/config用于所有SSH连接。我有一个非常简单的库存文件。
[apps]
app[998:999]
运行以下命令时,
ansible all -i ansible.cfg -m ping -vvvv
我会得到以下输出
<app999> (255, b'', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 47: Applying options for app???\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_addr: could not resolve name app999 as address: Name or service not known\r\ndebug3: resolve_canonicalize: attempting "app999" => "app999.vetdrive.io."\r\ndebug1: Canonicalized hostname "app999" => "app999.vetdrive.io"\r\ndebug1: Re-reading configuration after hostname canonicalisation\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 51: Applying options for app???.vetdrive.io\r\ndebug1: /home/hamzaafridi/.ssh/config line 55: Applying options for *.vetdrive.io\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W \'[%h]:%p\' bast.vetdrive.io\r\nCannot execute command-line and remote command.\r\n')
app999 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 47: Applying options for app???\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_addr: could not resolve name app999 as address: Name or service not known\r\ndebug3: resolve_canonicalize: attempting \"app999\" => \"app999.vetdrive.io.\"\r\ndebug1: Canonicalized hostname \"app999\" => \"app999.vetdrive.io\"\r\ndebug1: Re-reading configuration after hostname canonicalisation\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 51: Applying options for app???.vetdrive.io\r\ndebug1: /home/hamzaafridi/.ssh/config line 55: Applying options for *.vetdrive.io\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W '[%h]:%p' bast.vetdrive.io\r\nCannot execute command-line and remote command.",
"unreachable": true
}
,我不确定我在做什么错。我可以简单地做SSH App999即可访问服务器,并且工作正常。
任何帮助都将受到赞赏。
谢谢
I want ansible to use .ssh/config for all the ssh connection as we are using proxyJump using bastian servers. I have a very simple inventory file.
[apps]
app[998:999]
when running the following command
ansible all -i ansible.cfg -m ping -vvvv
I get the following output
<app999> (255, b'', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 47: Applying options for app???\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_addr: could not resolve name app999 as address: Name or service not known\r\ndebug3: resolve_canonicalize: attempting "app999" => "app999.vetdrive.io."\r\ndebug1: Canonicalized hostname "app999" => "app999.vetdrive.io"\r\ndebug1: Re-reading configuration after hostname canonicalisation\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 51: Applying options for app???.vetdrive.io\r\ndebug1: /home/hamzaafridi/.ssh/config line 55: Applying options for *.vetdrive.io\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W \'[%h]:%p\' bast.vetdrive.io\r\nCannot execute command-line and remote command.\r\n')
app999 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 47: Applying options for app???\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_addr: could not resolve name app999 as address: Name or service not known\r\ndebug3: resolve_canonicalize: attempting \"app999\" => \"app999.vetdrive.io.\"\r\ndebug1: Canonicalized hostname \"app999\" => \"app999.vetdrive.io\"\r\ndebug1: Re-reading configuration after hostname canonicalisation\r\ndebug1: Reading configuration data /home/hamzaafridi/.ssh/config\r\ndebug1: /home/hamzaafridi/.ssh/config line 51: Applying options for app???.vetdrive.io\r\ndebug1: /home/hamzaafridi/.ssh/config line 55: Applying options for *.vetdrive.io\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -vvv -W '[%h]:%p' bast.vetdrive.io\r\nCannot execute command-line and remote command.",
"unreachable": true
}
I am not sure what I doing wrong. I can simply do ssh app999 to access the server and it's working perfectly fine.
Any help is appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是.ssh/config I具有
remoteCommand byob
,该>与Ansible无效。The issue was with .ssh/config I had
RemoteCommand byob
which doesn't work with ansible.