10af3874b5
* 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
158 lines
4.6 KiB
YAML
158 lines
4.6 KiB
YAML
---
|
|
- name: Add initial SNMP manager
|
|
register: snmp_manager
|
|
win_snmp:
|
|
action: add
|
|
permitted_managers:
|
|
- 192.168.1.1
|
|
|
|
- name: Check initial SNMP manager exists in registry
|
|
register: snmp_manager_reg
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 1
|
|
|
|
- name: Assert initial SNMP manager is correct
|
|
assert:
|
|
that:
|
|
- snmp_manager is changed
|
|
- snmp_manager_reg.exists
|
|
- snmp_manager_reg.type == 'REG_SZ'
|
|
- snmp_manager_reg.value == '192.168.1.1'
|
|
|
|
- name: Add initial SNMP manager again
|
|
register: snmp_manager_again
|
|
win_snmp:
|
|
action: add
|
|
permitted_managers:
|
|
- 192.168.1.1
|
|
|
|
- name: Check no change occurred when adding SNMP manager again
|
|
assert:
|
|
that:
|
|
- snmp_manager_again is not changed
|
|
|
|
- name: Add next SNMP manager
|
|
register: snmp_manager_next
|
|
win_snmp:
|
|
action: add
|
|
permitted_managers:
|
|
- 192.168.1.2
|
|
|
|
- name: Check initial SNMP manager still exists in registry
|
|
register: snmp_manager_reg_orig
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 1
|
|
|
|
- name: Check next SNMP manager exists in registry
|
|
register: snmp_manager_reg_next
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 2
|
|
|
|
- name: Assert initial SNMP manager still exists
|
|
assert:
|
|
that:
|
|
- snmp_manager_reg_orig.exists
|
|
- snmp_manager_reg_orig.type == 'REG_SZ'
|
|
- snmp_manager_reg_orig.value == '192.168.1.1'
|
|
|
|
- name: Assert next SNMP manager exists
|
|
assert:
|
|
that:
|
|
- snmp_manager_next is changed
|
|
- snmp_manager_reg_next.exists
|
|
- snmp_manager_reg_next.type == 'REG_SZ'
|
|
- snmp_manager_reg_next.value == '192.168.1.2'
|
|
|
|
- name: Replace SNMP manager
|
|
register: snmp_manager_replace
|
|
win_snmp:
|
|
action: set
|
|
permitted_managers:
|
|
- 192.168.1.10
|
|
|
|
- name: Check next SNMP manager does not exist in registry
|
|
register: snmp_manager_reg_next_replace
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 2
|
|
|
|
- name: Check replace SNMP manager exists in registry (overrides original slot)
|
|
register: snmp_manager_reg_replace
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 1
|
|
|
|
- name: Assert replace SNMP manager exists and others are replaced
|
|
assert:
|
|
that:
|
|
- snmp_manager_replace is changed
|
|
- snmp_manager_reg_next_replace.exists == false
|
|
- snmp_manager_reg_replace.exists
|
|
- snmp_manager_reg_replace.type == 'REG_SZ'
|
|
- snmp_manager_reg_replace.value == '192.168.1.10'
|
|
|
|
# This task has already been tested
|
|
- name: Add another SNMP manager before testing removal
|
|
win_snmp:
|
|
action: add
|
|
permitted_managers:
|
|
- 192.168.1.20
|
|
|
|
- name: Remove the replaced SNMP manager
|
|
register: snmp_manager_remove
|
|
win_snmp:
|
|
action: remove
|
|
permitted_managers:
|
|
- 192.168.1.10
|
|
|
|
- name: Check replace SNMP manager is removed in registry
|
|
register: snmp_manager_reg_remove
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 1
|
|
|
|
- name: Check SNMP manager that was added for testing removal exists in registry
|
|
register: snmp_manager_reg_remove_add
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 2
|
|
|
|
- name: Assert removal of SNMP manager succeeded and next SNMP manager remains
|
|
assert:
|
|
that:
|
|
- snmp_manager_remove is changed
|
|
- snmp_manager_reg_remove.exists == false
|
|
- snmp_manager_reg_remove_add.exists
|
|
- snmp_manager_reg_remove_add.type == 'REG_SZ'
|
|
- snmp_manager_reg_remove_add.value == '192.168.1.20'
|
|
|
|
- name: Remove the replaced SNMP manager (again)
|
|
register: snmp_manager_remove
|
|
win_snmp:
|
|
action: remove
|
|
permitted_managers:
|
|
- 192.168.1.10
|
|
|
|
- name: Check replace SNMP manager is removed in registry (again)
|
|
register: snmp_manager_reg_remove
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 1
|
|
|
|
- name: Check SNMP manager that was added for testing removal exists in registry (again)
|
|
register: snmp_manager_reg_remove_add
|
|
win_reg_stat:
|
|
path: "{{ permitted_managers_key }}"
|
|
name: 2
|
|
|
|
- name: Assert removal of SNMP manager succeeded and next SNMP manager remains (again)
|
|
assert:
|
|
that:
|
|
- snmp_manager_remove is not changed
|
|
- snmp_manager_reg_remove.exists == false
|
|
- snmp_manager_reg_remove_add.exists
|
|
- snmp_manager_reg_remove_add.type == 'REG_SZ'
|
|
- snmp_manager_reg_remove_add.value == '192.168.1.20'
|