ansible-collections/cisco.nxos

NX-OS snmp_server module trap commands failing with multiple hyphen(-) and underscore(_) issues

jdetwiler16 opened this issue · 0 comments

SUMMARY

When trying to enter snmp-server traps commands, there are instances where the commands being entered have hyphens (-), but the switches themselves show the commands to be expecting underscores (_). This is very similar to bug ID 474

ISSUE TYPE
  • Bug Report
COMPONENT NAME

nxos_snmp_server

ANSIBLE VERSION
Virtual environment  ./.venv already exists, activating...
(.venv) [pamtelecom@usdc1netutilp01 ~]$ ansible --version
ansible [core 2.14.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/RPC3_WHQDM/pamtelecom/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/RPC3_WHQDM/pamtelecom/.venv/lib/python3.9/site-packages/ansible
  ansible collection location = /home/RPC3_WHQDM/pamtelecom/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/RPC3_WHQDM/pamtelecom/.venv/bin/ansible
  python version = 3.9.10 (main, Dec 14 2022, 09:49:02) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] (/home/RPC3_WHQDM/pamtelecom/.venv/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection Version
---------- -------
cisco.nxos 6.0.3
CONFIGURATION
CONFIG_FILE() = /etc/ansible/ansible.cfg
DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 20
DEFAULT_GATHERING(/etc/ansible/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/ansible/AnsibleInventory/inventory.yml']
DEFAULT_LOAD_CALLBACK_PLUGINS(/etc/ansible/ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = yaml
DEFAULT_STRATEGY(/etc/ansible/ansible.cfg) = free
DEFAULT_VAULT_PASSWORD_FILE(/etc/ansible/ansible.cfg) = /home/***/***/.ansible/.vault_key
DISPLAY_SKIPPED_HOSTS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/etc/ansible/ansible.cfg) = python3
OS / ENVIRONMENT

Confirmed underscore commands are valid on versions 9.3(10) and 9.3(13). These versions show no hyphenated commands, as shown in the ? output from the switches below

STEPS TO REPRODUCE

Using Azure DevOps as the front end and running the commands shown below in the playbook

      cisco.nxos.nxos_snmp_server:
        config:
          traps:
            entity:
              enable: true
              entity_fan_status_change: true
              entity_module_inserted: true
              entity_module_removed: true
              entity_module_status_change: true
              entity_power_out_change: true
              entity_power_status_change: true
              entity_sensor: true
        state: overridden
EXPECTED RESULTS

Command to be entered without errors. This can be done manually and successfully using underscores on the switch itself:

_USLB1I02ASW04(config)# snmp-server enable traps entity ?

cefcMIBEnableStatusNotification CefcMIBEnableStatusNotification
entity_fan_status_change Entity Fan Status Change
entity_mib_change Entity MIB change
entity_module_inserted Entity Module Inserted
entity_module_removed Entity Module Removed
entity_module_status_change Entity Module Status Change
entity_power_out_change Entity Power Out Change
entity_power_status_change Entity Power Status Change
entity_sensor Entity sensor
entity_unrecognised_module Entity Unrecognised Module

USLB1I02ASW04(config)#_

ACTUAL RESULTS

Command in Ansible errors out with the output below

task path: /home/vsts-svc/myagent/_work/10/s/ansible/import_tasks/snmp_update-task.yml:437
fatal: [uslb1i02asw04]: FAILED! => changed=false 
  module_stderr: |-
    snmp-server enable traps entity entity-fan-status-change
                                                           ^
    % Invalid command at '^' marker.
    USLB1I02ASW04(config)#
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error