首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >可能- Cisco NX-OS无法确定设备操作系统

可能- Cisco NX-OS无法确定设备操作系统
EN

Stack Overflow用户
提问于 2021-07-01 21:58:10
回答 1查看 251关注 0票数 0

我是Ansible上的新手,我正在尝试使用Ansible cisco.nxos模块从Cisco Nexus设备中提取一些典型的显示输出。

我使用实战手册中的cisco.nxos.nxos_command模块在NX-OS设备上运行show version。但是,在执行playbook时,我得到以下错误:

代码语言:javascript
复制
fatal: [Nx-01]: FAILED! =>
  msg: Unable to automatically determine host network os. Please manually configure ansible_network_os value for this host

但是,我在清单文件中指定了操作系统类型:

代码语言:javascript
复制
[nxos]
Nx-01

[nxos:vars]
ansible_connection=ansible.netcommon.network_cli
**ansible_network_os=cisco.nxos.nxos**
ansible_user=testuser
ansible_ssh_pass=test

以下是我正在使用的攻略:

代码语言:javascript
复制
---
- name: show version
  hosts: nxos
  gather_facts: false

  tasks:
    - name: show version
      cisco.nxos.nxos_command:
        commands: show version
      register: output

    -  debug: var=output.stdout_lines

我是不是遗漏了什么?与cisco.ios模块配合使用时,完全相同的设置完全适用于Cisco IOS。

EN

回答 1

Stack Overflow用户

发布于 2021-09-20 16:24:46

根据错误消息,缺少变量值ansible_network_os: cisco.nxos.nxos。在测试中,以下main.yaml运行正常。

代码语言:javascript
复制
- hosts: nxos
  gather_facts: false

  # Prepare execution environment
  # Doc: https://docs.ansible.com/ansible/latest/network/user_guide/platform_nxos.html

  vars:
    ansible_connection: ansible.netcommon.network_cli
    ansible_network_os: cisco.nxos.nxos
    ansible_become: yes
    ansible_become_method: enable
    ansible_user: testuser
    ansible_password: ********

  tasks:

    # Usage of command module
    # Doc: https://docs.ansible.com/ansible/latest/collections/cisco/nxos/nxos_command_module.html
  
    - name: Run command on remote device
      cisco.nxos.nxos_command:
        commands: show version
      register: results

    - name: Show results
      debug:
        msg: "{{ results.stdout_lines }}"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68211573

复制
相关文章

相似问题

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