Ssh proxycommand似乎不适用于ansible和我的环境
我尝试了很多组合来让它工作,但由于某些原因不能。我没有在我们的环境中使用密钥,因此必须使用密码 我也试过proxyjump和sshuttle 奇怪的是,ping模块可以正常工作,但当尝试其他模块或playbook时,它却无法正常工作 粗略设置为:Ssh proxycommand似乎不适用于ansible和我的环境,ssh,ansible,Ssh,Ansible,我尝试了很多组合来让它工作,但由于某些原因不能。我没有在我们的环境中使用密钥,因此必须使用密码 我也试过proxyjump和sshuttle 奇怪的是,ping模块可以正常工作,但当尝试其他模块或playbook时,它却无法正常工作 粗略设置为: 运行ubuntu并安装ansible的笔记本电脑 [笔记本电脑]-->[productionjumphost]-->[production\u iosxr\u路由器] ansible.cfg: [ssh_connection] pipelining
- 运行ubuntu并安装ansible的笔记本电脑
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o ControlPath=/tmp/ansible-%r@%h:%p -F ssh.config
[local]
192.168.xxx.xxx
[router]
production_iosxr_router ansible_connection=network_cli ansible_user=user ansible_ssh_pass=password
[router:vars]
ansible_network_os=iosxr
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q user@productionjumphost.fqdn.com.au"'
ansible_user=user
ansible_ssh_pass=password
---
- name: Network Getting Started First Playbook
hosts: router
gather_facts: no
connection: network_cli
tasks:
- name: show version
iosxr_command:
commands: show version
~/.ssh/config==ssh.cfg:(同时配置)
库存:
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o ControlPath=/tmp/ansible-%r@%h:%p -F ssh.config
[local]
192.168.xxx.xxx
[router]
production_iosxr_router ansible_connection=network_cli ansible_user=user ansible_ssh_pass=password
[router:vars]
ansible_network_os=iosxr
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q user@productionjumphost.fqdn.com.au"'
ansible_user=user
ansible_ssh_pass=password
---
- name: Network Getting Started First Playbook
hosts: router
gather_facts: no
connection: network_cli
tasks:
- name: show version
iosxr_command:
commands: show version
playbook.yml:
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o ControlPath=/tmp/ansible-%r@%h:%p -F ssh.config
[local]
192.168.xxx.xxx
[router]
production_iosxr_router ansible_connection=network_cli ansible_user=user ansible_ssh_pass=password
[router:vars]
ansible_network_os=iosxr
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q user@productionjumphost.fqdn.com.au"'
ansible_user=user
ansible_ssh_pass=password
---
- name: Network Getting Started First Playbook
hosts: router
gather_facts: no
connection: network_cli
tasks:
- name: show version
iosxr_command:
commands: show version
我可以运行临时ansible命令,并返回成功的ping:
结果:ansible production\u iosxr\u router-i inventory-m ping-VVV
production_iosxr_router | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"invocation": {
"module_args": {
"data": "pong"
}
},
"ping": "pong"
}
production_iosxr_router | FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"msg": "[Errno -2] Name or service not known"
}
运行剧本:ansible剧本-i inventory playbook.yml-vvv
production_iosxr_router | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"invocation": {
"module_args": {
"data": "pong"
}
},
"ping": "pong"
}
production_iosxr_router | FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"msg": "[Errno -2] Name or service not known"
}
您是否在ansible_ssh_common_args的清单文件中使用冒号而不是等号?@habeeberward我不这么认为。这可能是因为试图删除不应在公共域中的详细信息…但是,刚刚再次添加了所有配置文件,并使用equal而不是冒号,并出现以下错误:“msg”:“读取SSH协议标题时出错”-感谢您的响应btwnow我也得到了“协商失败:读取SSH协议标题时出错”。我们正在取得进展:看起来我的问题已经解决了;没有得到正确的验证。让我更新一下我到目前为止学到的知识,以便你能取得一些进步。我正在为连接:netconfig工作。我必须在/etc/ansible/hosts中设置“ansible\u netconf\u ssh\u config:True”,并在~/.ssh/config中添加proxy命令。我不需要设置ansible_ssh_common_args。在jump/bastion主机中还可以做一些事情。使用命令sudo journalctl-u ssh-f和sudo tail-f/var/log/auth.logs检查ssh日志是否在ansible_ssh_common_args的清单文件中使用冒号而不是等号?@habeeberward我不这么认为。这可能是因为试图删除不应在公共域中的详细信息…但是,刚刚再次添加了所有配置文件,并使用equal而不是冒号,并出现以下错误:“msg”:“读取SSH协议标题时出错”-感谢您的响应btwnow我也得到了“协商失败:读取SSH协议标题时出错”。我们正在取得进展:看起来我的问题已经解决了;没有得到正确的验证。让我更新一下我到目前为止学到的知识,以便你能取得一些进步。我正在为连接:netconfig工作。我必须在/etc/ansible/hosts中设置“ansible\u netconf\u ssh\u config:True”,并在~/.ssh/config中添加proxy命令。我不需要设置ansible_ssh_common_args。在jump/bastion主机中还可以做一些事情。使用命令sudojournalctl-ush-f和sudotail-f/var/log/auth.log检查ssh日志