From 0d3c5c4bac0580d03023bb811eac15f3ba88f9ad Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 7 Jan 2020 12:15:43 +0530 Subject: [PATCH] Fix nxos_snmp_community command ordering (#66094) Signed-off-by: NilashishC (cherry picked from commit 46744353678011d6e8556a0e936e1873fbecbe13) Add changelog for nxos_snmp_community fix Signed-off-by: NilashishC --- changelogs/fragments/66094_fix_nxos_snmp_community.yaml | 3 +++ lib/ansible/modules/network/nxos/nxos_snmp_community.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/66094_fix_nxos_snmp_community.yaml 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: