cisco.nxos.nxos_snmp_server fails with state replaced on nexus 5k and nexus 7k
SUMMARY
cisco.nxos.nxos_snmp_server fails with state replaced on nexus 5k and nexus 7k due to different syntax
ISSUE TYPE
- Bug Report
COMPONENT NAME
cisco.nxos.nxos_snmp_server
ANSIBLE VERSION
ansible [core 2.16.5]
config file = /Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg
configured module search path = ['/Users/jorgenspange/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/9.4.0_1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/jorgenspange/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.3 (main, Apr 9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/Cellar/ansible/9.4.0_1/libexec/bin/python)
jinja version = 3.1.3
libyaml = True
COLLECTION VERSION
Collection Version
---------- -------
cisco.nxos 8.0.0
# /opt/homebrew/Cellar/ansible/9.4.0_1/libexec/lib/python3.12/site-packages/ansible_collections
CONFIGURATION
ANSIBLE_COW_PATH(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = /opt/homebrew/bin/cowsay
ANSIBLE_COW_SELECTION(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = small
ANSIBLE_NOCOWS(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = False
ANSIBLE_PIPELINING(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = True
CONFIG_FILE() = /Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg
DEFAULT_FORKS(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = 10
DEFAULT_GATHERING(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = smart
DEFAULT_HOST_LIST(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = ['/Users/jorgenspange/Documents/git/ansible-network-automation/inventory/S-TEST']
DEFAULT_ROLES_PATH(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = ['/Users/jorgenspange/Documents/git/ansible-network-automation/roles']
DEFAULT_STDOUT_CALLBACK(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = yaml
DEFAULT_TIMEOUT(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = 120
DEFAULT_VAULT_PASSWORD_FILE(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = /Users/jorgenspange/Documents/git/ansible-network-automation/.secret/vault_pass.txt
DISPLAY_SKIPPED_HOSTS(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = False
HOST_KEY_CHECKING(/Users/jorgenspange/Documents/git/ansible-network-automation/ansible.cfg) = False
OS / ENVIRONMENT
MacBook Pro 2021 M1
STEPS TO REPRODUCE
Using state replaced or overridden on snmpv3 credentials on N5k and N7k makes it fail as the syntax is localizedkey and not localizedV2key
fatal: [N7K]: FAILED! => changed=false
module_stderr: |-
xxxxxxxx localizedV2key
^
% Invalid command at '^' marker.
N7K(config)#
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
@jorgenspange What is the NX-OS versions running on the 7K and 5K?
@NilashishC
Thanks for prompt reply, these are the versions:
N5k: 7.3(13)N1(1) N7k: 8.4(6a)
@NilashishC managed to figure this out, as my playbook actually specified v2key for these hosts aswell.
Although there are still many problems with this module, if i try state deleted and a user is not there it fails:
fatal: [5k]: FAILED! => changed=false
module_stderr: |-
no snmp-server user snmpuser use-ipv4acl SNMP
user not found
5k(config)#
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
Guess it's the same issue that i addressed here, where users are removed or added every run when using state replaced or overridden: https://github.com/ansible-collections/cisco.nxos/issues/803
@jorgenspange I have responded to #803. Please have a look when you have time.
Regarding this issue, you're correct, this module supports for localizedkey and localizedv2key. You need to specify the correct one as per your target device.
With that, I'll close this ticket. We can continue discussing the overridden issue in #803. Thanks!