fix nxos_snmp_community issues (#39258)
parent
86817cdd52
commit
1afec5a48e
|
@ -48,8 +48,7 @@ options:
|
||||||
- Group to which the community belongs.
|
- Group to which the community belongs.
|
||||||
acl:
|
acl:
|
||||||
description:
|
description:
|
||||||
- ACL name to filter snmp requests.
|
- ACL name to filter snmp requests or keyword 'default'.
|
||||||
default: 1
|
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Manage the state of the resource.
|
- Manage the state of the resource.
|
||||||
|
@ -150,7 +149,8 @@ def get_snmp_community(module, name):
|
||||||
def config_snmp_community(delta, community):
|
def config_snmp_community(delta, community):
|
||||||
CMDS = {
|
CMDS = {
|
||||||
'group': 'snmp-server community {0} group {group}',
|
'group': 'snmp-server community {0} group {group}',
|
||||||
'acl': 'snmp-server community {0} use-acl {acl}'
|
'acl': 'snmp-server community {0} use-acl {acl}',
|
||||||
|
'no_acl': 'no snmp-server community {0} use-acl {no_acl}'
|
||||||
}
|
}
|
||||||
commands = []
|
commands = []
|
||||||
for k, v in delta.items():
|
for k, v in delta.items():
|
||||||
|
@ -203,6 +203,10 @@ def main():
|
||||||
args = dict(group=group, acl=acl)
|
args = dict(group=group, acl=acl)
|
||||||
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
proposed = dict((k, v) for k, v in args.items() if v is not None)
|
||||||
delta = dict(set(proposed.items()).difference(existing.items()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
if delta.get('acl') == 'default':
|
||||||
|
delta.pop('acl')
|
||||||
|
if existing.get('acl'):
|
||||||
|
delta['no_acl'] = existing.get('acl')
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
nxos_snmp_community: &config
|
nxos_snmp_community: &config
|
||||||
community: TESTING7
|
community: TESTING7
|
||||||
group: network-operator
|
group: network-operator
|
||||||
#access: ro
|
|
||||||
state: present
|
state: present
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -34,6 +33,22 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
|
- name: Change snmp_community group
|
||||||
|
nxos_snmp_community: &chg
|
||||||
|
community: TESTING7
|
||||||
|
group: network-admin
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: Idempotence Check
|
||||||
|
nxos_snmp_community: *chg
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
- name: Remove snmp_community
|
- name: Remove snmp_community
|
||||||
nxos_snmp_community: *remove
|
nxos_snmp_community: *remove
|
||||||
register: result
|
register: result
|
||||||
|
@ -91,6 +106,40 @@
|
||||||
|
|
||||||
- assert: *false
|
- assert: *false
|
||||||
|
|
||||||
|
- name: Change acl
|
||||||
|
nxos_snmp_community: &chgacl
|
||||||
|
community: TESTING7
|
||||||
|
access: rw
|
||||||
|
acl: new_acl
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: Idempotence Check
|
||||||
|
nxos_snmp_community: *chgacl
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
- name: Remove acl
|
||||||
|
nxos_snmp_community: &removeacl
|
||||||
|
community: TESTING7
|
||||||
|
access: rw
|
||||||
|
acl: default
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: Idempotence Check
|
||||||
|
nxos_snmp_community: *removeacl
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
nxos_snmp_community: *remove
|
nxos_snmp_community: *remove
|
||||||
|
|
|
@ -1198,7 +1198,6 @@ lib/ansible/modules/network/nxos/nxos_pim_interface.py E326
|
||||||
lib/ansible/modules/network/nxos/nxos_pim_rp_address.py E326
|
lib/ansible/modules/network/nxos/nxos_pim_rp_address.py E326
|
||||||
lib/ansible/modules/network/nxos/nxos_reboot.py E325
|
lib/ansible/modules/network/nxos/nxos_reboot.py E325
|
||||||
lib/ansible/modules/network/nxos/nxos_smu.py E324
|
lib/ansible/modules/network/nxos/nxos_smu.py E324
|
||||||
lib/ansible/modules/network/nxos/nxos_snmp_community.py E324
|
|
||||||
lib/ansible/modules/network/nxos/nxos_system.py E325
|
lib/ansible/modules/network/nxos/nxos_system.py E325
|
||||||
lib/ansible/modules/network/nxos/nxos_vpc.py E324
|
lib/ansible/modules/network/nxos/nxos_vpc.py E324
|
||||||
lib/ansible/modules/network/nxos/nxos_vpc_interface.py E325
|
lib/ansible/modules/network/nxos/nxos_vpc_interface.py E325
|
||||||
|
|
Loading…
Reference in New Issue