我的剧本:
- name: get junos facts
hosts: sw
# connection: local
gather_facts: no
roles:
- juniper.junos
tasks:
- name: Retrieve Junos OS version
junipernetworks.junos.junos_command:
commands: show version
主持人:
[sw]
EX4200-2
EX4200-1
变量:
ansible_network_os: juniper_junos
Ansible 配置
ansible-playbook [core 2.12.1]
config file = /usr/local/san/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/python/python38/lib/python3.8/site-packages/ansible
ansible collection location = /root/.ansible/collections/ansible_collections
executable location = /usr/local/python/python38/bin/ansible-playbook
python version = 3.8.10 (default, Dec 30 2021, 10:44:47) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
jinja version = 3.0.3
libyaml = True
运行剧本的结果
[WARNING]: sftp transfer mechanism failed on [10.1.1.196]. Use ANSIBLE_DEBUG=1 to see detailed information
<10.1.1.196> SSH: EXEC sshpass -d13 scp -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="admin"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0d45650285 /root/.ansible/tmp/ansible-local-3715dofr3qmk/tmpiaq5tnso '[10.1.1.196]:'"'"'error: unknown command: /bin/sh/AnsiballZ_junos_command.py'"'"''
[WARNING]: scp transfer mechanism failed on [10.1.1.196]. Use ANSIBLE_DEBUG=1 to see detailed information
<10.1.1.196> ESTABLISH SSH CONNECTION FOR USER: xxx
<10.1.1.196> SSH: EXEC sshpass -d13 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="admin"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0d45650285 10.1.1.196 'dd of=error: unknown command: /bin/sh/AnsiballZ_junos_command.py bs=65536'
<10.1.1.254> (0, b'\nerror: unknown command: /bin/sh\n', b'')
...
fatal: [EX4200-2]: FAILED! => {
"changed": false,
"module_stderr": "Shared connection to 10.1.1.196 closed.\r\n",
"module_stdout": "\r\nerror: unknown command: /bin/sh\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}
看起来 SCP 和 SFTP 有问题。但是我手动执行SCP和SFTP是正常的。
我该如何解决这个错误?