Closed abhishgu closed 9 months ago
@abhishgu Could you please share the following with us to debug this further?
As a side note, the commands show version
and show inventory
are always run by the NX-OS Ansible CLICONF plugin when interacting with a Cisco Nexus appliance to gather metadata that is later used by modules mentioned in the play. These commands are known to work with a variety of Nexus 3k, 7k, 9k that we have tested our modules with and have been a part of the CLICONF plugin for at least 6 years (ansible 2.5.0+). It is surprising why the device CLI reports that the show inventory
command is invalid in your case. Are you sure that the target appliances are Nexus switches?
Thank you.
hi @NilashishC , I can reproduce it with cisco apic devices. II have this ansible:
$ ansible --version
ansible [core 2.14.9]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/carlo.bongiovanni/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /home/carlo.bongiovanni/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.9.18 (main, Sep 7 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
I have cisco nxos galaxy collection, version 6.0.0.
My task fails with FAILED! => {"changed": false, "module_stderr": "show inventory\r\r\nError: Invalid argument 'inventory '. Please check syntax in command reference g\r\nuide\r\n\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r\r\u001b[0m\u001b[27m\u001b[24m\u001b[Jid12ms-apic3# \u001b[K", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"}
here you find the ansible.log, created from device interaction logs: ansible.log
And my play is very easy:
- name: Execute commands on network devices
hosts: all
gather_facts: false
tasks:
- name: "Run the NXOS command"
cisco.nxos.nxos_command:
commands:
- command: show version
output: json
vars:
ansible_persistent_log_messages: True
can you provide a fix?
Thanks C.
@carlobongiovanni As explained in my previous comment, the commands show version
and show inventory
are always run by the NX-OS Ansible CLICONF plugin when interacting with a Cisco Nexus appliance to gather metadata that is later used by modules mentioned in the play.
This collection is compatible only with Cisco Nexus switches in NX-OS mode (and partially compatible with NX-OS on Cisco MDS). From the traceback you shared, show inventory
does not seem to be valid in APIC/ACI mode and hence, it's not working.
hi @NilashishC , thanks for your answer, now I understand the issue. From my point of view the command function should just help to execute a command, and should not hide the execution of other commands. Or at least it should be possible to disable such a behaviour. But ok, I now understand I was using the wrong ansible collection for my network appliance. Thanks for your answer. I believe the issue can be closed.
@abhishgu Since there's no activity on this issue, I'll be closing it for now. Please feel free to re-open this or create a new ticket, if you'd like to take this further.
Thank you.
SUMMARY
commands
module works differently with Ansible core 2.15.ISSUE TYPE
COLLECTION VERSION
Latest 5.1.0 cisco.nxos collection version.
STEPS TO REPRODUCE
ACTUAL RESULTS
EXPECTED RESULTS
It should register
show inventory
outcome in Ansible core 2.15.