mirror of https://github.com/ansible/ansible.git
Fix nxos_snmp_community idempotence issue (#30388)
* Fix nxos_snmp_community idempotence issue
* Use passed in name to filter
* Test updates and remove unused method
(cherry picked from commit 9af6dc4751
)
pull/30434/merge
parent
91e1a5fe16
commit
c73e1b5e68
@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_nxos_tests
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
# Use block to ensure that both cli and nxapi tests
|
||||
# will run even if there are failures or errors.
|
||||
- block:
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
always:
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: collect all nxapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/nxapi"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: enable nxapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- feature nxapi
|
||||
- nxapi http port 80
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: disable nxapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- no feature nxapi
|
||||
provider: "{{ cli }}"
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
- set_fact: connection="{{ cli }}"
|
||||
|
||||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
@ -0,0 +1,96 @@
|
||||
---
|
||||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_snmp_community sanity test"
|
||||
|
||||
- name: Setup - Remove snmp_community if configured
|
||||
nxos_snmp_community: &remove
|
||||
community: TESTING7
|
||||
group: network-operator
|
||||
state: absent
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- block:
|
||||
|
||||
- name: Configure snmp_community group
|
||||
nxos_snmp_community: &config
|
||||
community: TESTING7
|
||||
group: network-operator
|
||||
#access: ro
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Idempotence Check
|
||||
nxos_snmp_community: *config
|
||||
register: result
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Remove snmp_community
|
||||
nxos_snmp_community: *remove
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: Idempotence Check
|
||||
nxos_snmp_community: *remove
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: Configure snmp_community access read-only
|
||||
nxos_snmp_community: &configaccess
|
||||
community: TESTING7
|
||||
access: ro
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: Idempotence Check
|
||||
nxos_snmp_community: *configaccess
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: Remove snmp_community
|
||||
nxos_snmp_community: *remove
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: Idempotence Check
|
||||
nxos_snmp_community: *remove
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: Configure snmp_community access read-write
|
||||
nxos_snmp_community: &configaccessrw
|
||||
community: TESTING7
|
||||
access: rw
|
||||
acl: ansible_acl
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: Idempotence Check
|
||||
nxos_snmp_community: *configaccessrw
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
always:
|
||||
- name: Cleanup
|
||||
nxos_snmp_community: *remove
|
||||
|
||||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_snmp_community sanity test"
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
- set_fact: connection="{{ nxapi }}"
|
||||
|
||||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
Loading…
Reference in New Issue