--- - 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'