我是Ansible上的新手,我正在尝试使用Ansible cisco.nxos模块从Cisco Nexus设备中提取一些典型的显示输出。
我使用实战手册中的cisco.nxos.nxos_command模块在NX-OS设备上运行show version。但是,在执行playbook时,我得到以下错误:
fatal: [Nx-01]: FAILED! =>
msg: Unable to automatically determine host network os. Please manually configure ansible_network_os value for this host但是,我在清单文件中指定了操作系统类型:
[nxos]
Nx-01
[nxos:vars]
ansible_connection=ansible.netcommon.network_cli
**ansible_network_os=cisco.nxos.nxos**
ansible_user=testuser
ansible_ssh_pass=test以下是我正在使用的攻略:
---
- 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。
发布于 2021-09-20 16:24:46
根据错误消息,缺少变量值ansible_network_os: cisco.nxos.nxos。在测试中,以下main.yaml运行正常。
- 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 }}"https://stackoverflow.com/questions/68211573
复制相似问题