diff --git a/changelogs/fragments/66094_fix_nxos_snmp_community.yaml b/changelogs/fragments/66094_fix_nxos_snmp_community.yaml new file mode 100644 index 00000000000..5a6de750298 --- /dev/null +++ b/changelogs/fragments/66094_fix_nxos_snmp_community.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Fix ordering of the commands sent in nxos_snmp_community (https://github.com/ansible/ansible/pull/66094). diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_community.py b/lib/ansible/modules/network/nxos/nxos_snmp_community.py index b0c4a0cfb13..7755782224f 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_community.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_community.py @@ -153,10 +153,13 @@ def config_snmp_community(delta, community): 'no_acl': 'no snmp-server community {0} use-acl {no_acl}' } commands = [] - for k, v in delta.items(): + for k in delta.keys(): cmd = CMDS.get(k).format(community, **delta) if cmd: - commands.append(cmd) + if 'group' in cmd: + commands.insert(0, cmd) + else: + commands.append(cmd) cmd = None return commands @@ -220,6 +223,7 @@ def main(): commands.append(command) cmds = flatten_list(commands) + if cmds: results['changed'] = True if not module.check_mode: