首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Juniper设备上的不可操作失败,"sftp/scp传输机制失败“

Juniper设备上的不可操作失败,"sftp/scp传输机制失败“
EN

Stack Overflow用户
提问于 2022-02-15 07:20:32
回答 2查看 416关注 0票数 0

我的剧本:

代码语言:javascript
运行
复制
- 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

东道主:

代码语言:javascript
运行
复制
[sw]
EX4200-2
EX4200-1

vars:

代码语言:javascript
运行
复制
ansible_network_os: juniper_junos

不可调配置

代码语言:javascript
运行
复制
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

运行剧本的结果

代码语言:javascript
运行
复制
[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是正常的。

我怎样才能纠正这个错误?

EN

Stack Overflow用户

回答已采纳

发布于 2022-02-15 09:45:50

讯息

代码语言:javascript
运行
复制
MODULE FAILURE
error: unknown command: /bin/sh

指示远程节点上没有shell、缺少权限等。

正如您已经指出的,要使用Ansible Collection Junipernetworks.Junos中的模块,根据Junos OS平台选项,必须正确配置连接设置。

代码语言:javascript
运行
复制
---
- name: Get Junos facts
  hosts: sw
  gather_facts: false

  vars:

    ansible_network_os: juniper_junos
    ansible_connection: ansible.netcommon.network_cli
  
  roles:

    - juniper.junos

  tasks:

    - name: Retrieve Junos OS version
      junipernetworks.junos.junos_command:
        commands: show version
      regsiter: show_version

此外,建议将junos_facts用于从运行Juniper Junos的远程设备中收集事实中的示例

代码语言:javascript
运行
复制
- name: Collect default set of facts and configuration
  junipernetworks.junos.junos_facts:
    gather_subset: config
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71122462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档