我无法在 Ansible 2.1 中运行 ios_command 模块来在我的 cisco 路由器上执行命令。
我写了一本用于在 cisco 路由器上测试 ios_command 模块的剧本。
以下是我写的剧本
---
- hosts: router2
tasks:
- ios_command:
username: cisco
password: cisco
# host: router2.3node.example.com
commands:
- show version
register: output
- debug: msg="Hello World! {{ output.stdout }}"
但是剧本失败并显示以下消息:
fatal: [router2.3node.example.com]: UNREACHABLE! => {"changed": false,
"msg": "Failed to connect to the host via ssh.", "unreachable": true}
和价值unreachable=1
在调试模式下运行时还可以找到输出:
TASK [setup]
*******************************************************************
Using module file /home/cisco/ansible_dev/ansible/lib/ansible/modules
/core/system/setup.py
<router2.3node.example.com> ESTABLISH SSH CONNECTION FOR USER: None
<router2.3node.example.com> SSH: EXEC ssh -C -q -o ControlMaster=auto
-o ControlPersist=60s -o KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-
keyex,hostbased,publickey -o PasswordAuthentication=no -o
ConnectTimeout=10 -o ControlPath=/home/cisco/.ansible/cp/ansible-
ssh-%h-%p-%r router2.3node.example.com '/bin/sh -c '"'"'( umask 77 &&
mkdir -p "` echo $HOME/.ansible/tmp/ansible-
tmp-1464109982.9-18150317646623 `" && echo ansible-
tmp-1464109982.9-18150317646623="` echo $HOME/.ansible/tmp/ansible-
tmp-1464109982.9-18150317646623 `" ) && sleep 0'"'"''
fatal: [router2.3node.example.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
如果有人尝试过同样的方法并解决了这个问题,请告诉我。