ansible/test/integration/targets/win_snmp/tasks/snmp_community.yml
Michael Cassaniti 10af3874b5 win_snmp: Initial commit (#45710)
* win_snmp: Initial commit

* win_snmp: Better handling of lists

* win_snmp: Documentation fixes

* win_snmp: Updated documentation to match parameters

* win_snmp: Added integration tests

* win_snmp: Fixed typo in test

* win_snmp: Adjusted parameter checks to match documentation

* win_snmp: Updated option descriptions to be full sentences

* win_snmp: Better type checking and output suppression

* win_snmp: Fixed unset managers and communities

* win_snmp: Fixed skipping default registry keys

* win_snmp: Migrated to using add/set/remove action from replace

* win_snmp: Fixed check mode

* win_snmp: Fixed setting action and documentation. Expanded tests.

* win_snmp: Efficiency changes and documentation cleanup
  * Added example of explicitly setting an empty set of managers to
documentation
  * Made sure set will only remove items if there is a list of items
provided. This list can be of length 0
  * Improved efficiency in selecting next index for SNMP manager
  * Updated tests

* win_snmp: Added output of permitted managers and community strings

* win_snmp: Documentation fix
2018-11-22 06:55:10 +10:00

165 lines
5.1 KiB
YAML

---
- name: Add initial SNMP community
register: snmp_community
win_snmp:
action: add
community_strings:
- ansible-ro-test
- name: Check initial SNMP community exists in registry
register: snmp_community_reg
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-test
- name: Assert initial SNMP community is correct
assert:
that:
- snmp_community is changed
- snmp_community_reg.exists
- snmp_community_reg.type == 'REG_DWORD'
- snmp_community_reg.value == 4
- name: Add initial SNMP community again
register: snmp_community_again
win_snmp:
action: add
community_strings:
- ansible-ro-test
- name: Check no change occurred when adding SNMP community again
assert:
that:
- snmp_community_again is not changed
- name: Add next SNMP community
register: snmp_community_next
win_snmp:
action: add
community_strings:
- ansible-ro-test-next
- name: Check initial SNMP community still exists in registry
register: snmp_community_reg_orig
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-test
- name: Check next SNMP community exists in registry
register: snmp_community_reg_next
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-test-next
- name: Assert initial SNMP community still exists
assert:
that:
- snmp_community_reg_orig.exists
- snmp_community_reg_orig.type == 'REG_DWORD'
- snmp_community_reg_orig.value == 4
- name: Assert next SNMP community exists
assert:
that:
- snmp_community_next is changed
- snmp_community_reg_next.exists
- snmp_community_reg_next.type == 'REG_DWORD'
- snmp_community_reg_next.value == 4
- name: Replace SNMP community
register: snmp_community_replace
win_snmp:
action: set
community_strings:
- ansible-ro-test-replace
- name: Check initial SNMP community does not exist in registry
register: snmp_community_reg_orig_replace
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-test
- name: Check next SNMP community does not exist in registry
register: snmp_community_reg_next_replace
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-test-next
- name: Check replace SNMP community exists in registry
register: snmp_community_reg_replace
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-test-replace
- name: Assert replace SNMP community exists and others are replaced
assert:
that:
- snmp_community_replace is changed
- snmp_community_reg_orig_replace.exists == false
- snmp_community_reg_next_replace.exists == false
- snmp_community_reg_replace.exists
- snmp_community_reg_replace.type == 'REG_DWORD'
- snmp_community_reg_replace.value == 4
# This task has already been tested
- name: Add another SNMP community before testing removal
win_snmp:
action: add
community_strings:
- ansible-ro-remove-add
- name: Remove the replaced SNMP community
register: snmp_community_remove
win_snmp:
action: remove
community_strings:
- ansible-ro-test-replace
- name: Check replace SNMP community is removed in registry
register: snmp_community_reg_remove
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-test-replace
- name: Check SNMP community that was added for testing removal exists in registry
register: snmp_community_reg_remove_add
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-remove-add
- name: Assert removal of SNMP community succeeded and next SNMP community remains
assert:
that:
- snmp_community_remove is changed
- snmp_community_reg_remove.exists == false
- snmp_community_reg_remove_add.exists
- snmp_community_reg_remove_add.type == 'REG_DWORD'
- snmp_community_reg_remove_add.value == 4
- name: Remove the replaced SNMP community (again)
register: snmp_community_remove
win_snmp:
action: remove
community_strings:
- ansible-ro-test-replace
- name: Check replace SNMP community is removed in registry (again)
register: snmp_community_reg_remove
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-test-replace
- name: Check SNMP community that was added for testing removal exists in registry (again)
register: snmp_community_reg_remove_add
win_reg_stat:
path: "{{ valid_communities_key }}"
name: ansible-ro-remove-add
- name: Assert removal of SNMP community succeeded and next SNMP community remains (again)
assert:
that:
- snmp_community_remove is not changed
- snmp_community_reg_remove.exists == false
- snmp_community_reg_remove_add.exists
- snmp_community_reg_remove_add.type == 'REG_DWORD'
- snmp_community_reg_remove_add.value == 4