diff options
author | Jordan Borean <jborean93@gmail.com> | 2019-03-07 20:41:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-07 20:41:52 +0100 |
commit | 072fa54b50eba8793a380970ea3390b2ac52cdb8 (patch) | |
tree | 5cce7ac0b8e982a7eb594cccca32c7cd529a5b5e /test/integration | |
parent | Trying to work around spurious test failures. (#53472) (diff) | |
download | ansible-072fa54b50eba8793a380970ea3390b2ac52cdb8.tar.xz ansible-072fa54b50eba8793a380970ea3390b2ac52cdb8.zip |
win reg - Support special chars in path (#53305)
* win reg - Support special chars in path
* Added deprecation warning for path separators
Diffstat (limited to 'test/integration')
8 files changed, 494 insertions, 398 deletions
diff --git a/test/integration/targets/win_reg_stat/defaults/main.yml b/test/integration/targets/win_reg_stat/defaults/main.yml new file mode 100644 index 0000000000..a714e4399d --- /dev/null +++ b/test/integration/targets/win_reg_stat/defaults/main.yml @@ -0,0 +1,2 @@ +--- +test_reg_path: Test Key / [&Ansible*] diff --git a/test/integration/targets/win_reg_stat/files/test_reg.reg b/test/integration/targets/win_reg_stat/files/test_reg.reg deleted file mode 100644 index 64a3fc6971..0000000000 --- a/test/integration/targets/win_reg_stat/files/test_reg.reg +++ /dev/null @@ -1,24 +0,0 @@ -Windows Registry Editor Version 5.00 - -[HKEY_CURRENT_USER\Test] - -[HKEY_CURRENT_USER\Test\nested] -"string"="test" -"binary"=hex:01,16 -"dword"=dword:00000001 -"qword"=hex(b):01,00,00,00,00,00,00,00 -"multi"=hex(7):61,00,2c,00,20,00,62,00,00,00,63,00,00,00,00,00 -"expand"=hex(2):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,64,00,69,\ - 00,72,00,00,00 - -[HKEY_CURRENT_USER\Test\nested\nest1] -"dontcare"="" - -[HKEY_CURRENT_USER\Test\nested\nest2] - - -[HKEY_CURRENT_USER\Test\single] -"string1"="" -"string2"="abc123" -"none"=hex(0): -"none1"=hex(0):00 diff --git a/test/integration/targets/win_reg_stat/tasks/main.yml b/test/integration/targets/win_reg_stat/tasks/main.yml index ebaa37d233..654aeebd11 100644 --- a/test/integration/targets/win_reg_stat/tasks/main.yml +++ b/test/integration/targets/win_reg_stat/tasks/main.yml @@ -1,322 +1,29 @@ --- -- name: test - win_file: - path: "{{win_output_dir}}" - state: absent - -- name: make sure win output dir exists - win_file: - path: "{{win_output_dir}}" - state: directory - -- name: template out test registry structure - win_copy: - src: test_reg.reg - dest: "{{win_output_dir}}\\raw_test_reg.reg" - -- name: convert the line endings to the windows variant - win_shell: Get-Content "{{win_output_dir}}\raw_test_reg.reg" | Set-Content "{{win_output_dir}}\test_reg.reg" - -- name: import test registry structure - win_regmerge: - path: "{{win_output_dir}}\\test_reg.reg" - - name: get value of expand string %windir% win_command: powershell.exe $env:windir register: win_dir_value -- name: expect failure when not passing in path option - win_reg_stat: - name: a - register: actual - failed_when: "actual.msg != 'Get-AnsibleParam: Missing required argument: path'" - -- name: expect failure when passing in an invalid hive - win_reg_stat: - path: ABCD:\test - register: actual - failed_when: actual.msg != "the hive in path is 'ABCD'; must be 'HKCR', 'HKCC', 'HKCU', 'HKLM' or 'HKU'" - -- name: get known nested reg key structure for testing with short hive form - win_reg_stat: - path: HKCU:\Test\nested - register: actual_short - -- name: get known nested reg key structure for testing with quoted yaml - win_reg_stat: - path: "HKCU:\\Test\\nested" - register: actual_quoted - -- name: set expected value for reg structure - set_fact: - expected: - changed: false - exists: true - failed: false - properties: - binary: { raw_value: ["0x01", "0x16"], type: 'REG_BINARY', value: [1, 22] } - dword: { raw_value: 1, type: 'REG_DWORD', value: 1 } - expand: { raw_value: '%windir%\dir', type: 'REG_EXPAND_SZ', value: "{{win_dir_value.stdout_lines[0]}}\\dir" } - multi: { raw_value: ['a, b', 'c'], type: 'REG_MULTI_SZ', value: ['a, b', 'c'] } - qword: { raw_value: 1, type: 'REG_QWORD', value: 1 } - string: { raw_value: 'test', type: 'REG_SZ', value: 'test' } - sub_keys: - - nest1 - - nest2 - -- name: validate test - assert: - that: - - "actual_short == expected" - - "actual_quoted == expected" - -- name: get known reg key with no sub keys but some properties - win_reg_stat: - path: HKCU:\Test\single - register: actual - -- name: set expected value for reg key with no sub keys but some properties - set_fact: - expected: - changed: false - exists: true - failed: false - properties: - none: { raw_value: [], type: 'REG_NONE', value: [] } - none1: { raw_value: ["0x00"], type: 'REG_NONE', value: [0] } - string1: { raw_value: '', type: 'REG_SZ', value: '' } - string2: { raw_value: 'abc123', type: 'REG_SZ', value: 'abc123' } - sub_keys: [] - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get known reg key without sub keys and properties - win_reg_stat: - path: HKCU:\Test\nested\nest2 - register: actual - -- name: set expected value for reg key without sub keys or properties - set_fact: - expected: - changed: false - exists: true - failed: false - properties: {} - sub_keys: [] - register: expected - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get non-existent reg key - win_reg_stat: - path: HKCU:\Test\Thispathwillneverexist - register: actual - -- name: set expected value for non-existent reg key - set_fact: - expected: - changed: false - exists: false - failed: false - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get string property - win_reg_stat: - path: HKCU:\Test\nested - name: string - register: actual - -- name: set expected string property - set_fact: - expected: - changed: false - exists: true - failed: false - raw_value: 'test' - type: 'REG_SZ' - value: 'test' - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get expand string property - win_reg_stat: - path: HKCU:\Test\nested - name: expand - register: actual - -- name: set expected expand string property - set_fact: - expected: - changed: false - exists: true - failed: false - raw_value: '%windir%\dir' - type: 'REG_EXPAND_SZ' - value: "{{win_dir_value.stdout_lines[0]}}\\dir" - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get multi string property - win_reg_stat: - path: HKCU:\Test\nested - name: multi - register: actual - -- name: set expected multi string property - set_fact: - expected: - changed: false - exists: true - failed: false - raw_value: ['a, b', 'c'] - type: 'REG_MULTI_SZ' - value: ['a, b', 'c'] - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get binary property - win_reg_stat: - path: HKCU:\Test\nested - name: binary - register: actual - -- name: set expected binary property - set_fact: - expected: - changed: false - exists: true - failed: false - raw_value: ["0x01", "0x16"] - type: 'REG_BINARY' - value: [1, 22] - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get dword property - win_reg_stat: - path: HKCU:\Test\nested - name: dword - register: actual - -- name: set expected dword property - set_fact: - expected: - changed: false - exists: true - failed: false - raw_value: 1 - type: 'REG_DWORD' - value: 1 - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get qword property - win_reg_stat: - path: HKCU:\Test\nested - name: qword - register: actual - -- name: set expected qword property - set_fact: - expected: - changed: false - exists: true - failed: false - raw_value: 1 - type: 'REG_QWORD' - value: 1 - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get none property - win_reg_stat: - path: HKCU:\Test\single - name: none - register: actual - -- name: set expected none property - set_fact: - expected: - changed: false - exists: true - failed: false - raw_value: [] - type: 'REG_NONE' - value: [] - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get none with value property - win_reg_stat: - path: HKCU:\Test\single - name: none1 - register: actual - -- name: set expected none with value property - set_fact: - expected: - changed: false - exists: true - failed: false - raw_value: ["0x00"] - type: 'REG_NONE' - value: [0] - -- name: validate test - assert: - that: - - "actual == expected" - -- name: get non-existence property - win_reg_stat: - path: HKCU:\Test\single - name: doesnotexist - register: actual - -- name: set expected non-existence property - set_fact: - expected: - changed: false - exists: false - failed: false - -- name: validate test - assert: - that: - - "actual == expected" +- name: template out test registry structure + win_template: + src: test_reg.reg.j2 + dest: '{{ win_output_dir }}\test_reg.reg' -- name: remove registry entry - win_regedit: - path: HKCU:\Test - state: absent +- name: import test registry structure + win_regmerge: + path: '{{ win_output_dir }}\test_reg.reg' + +- block: + - name: run tests + import_tasks: tests.yml + + always: + - name: remove test registry key + win_regedit: + path: HKCU:\{{ test_reg_path }} + state: absent + delete_key: True + + - name: remove template registry file + win_file: + path: '{{ win_output_dir }}\test_reg.reg' + state: absent diff --git a/test/integration/targets/win_reg_stat/tasks/tests.yml b/test/integration/targets/win_reg_stat/tasks/tests.yml new file mode 100644 index 0000000000..285b501a4a --- /dev/null +++ b/test/integration/targets/win_reg_stat/tasks/tests.yml @@ -0,0 +1,364 @@ +--- +- name: expect failure when not passing in path option + win_reg_stat: + name: a + register: actual + failed_when: "actual.msg != 'Get-AnsibleParam: Missing required argument: path'" + +- name: expect failure when passing in an invalid hive + win_reg_stat: + path: ABCD:\test + register: actual + failed_when: 'actual.msg != "path: ABCD:\\test is not a valid registry path, see module documentation for examples."' + +- name: get known nested reg key structure + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\nested + register: actual + +- name: set expected value for reg structure + set_fact: + expected: + changed: false + exists: true + failed: false + properties: + binary: { raw_value: ["0x01", "0x16"], type: 'REG_BINARY', value: [1, 22] } + dword: { raw_value: 1, type: 'REG_DWORD', value: 1 } + expand: { raw_value: '%windir%\dir', type: 'REG_EXPAND_SZ', value: "{{win_dir_value.stdout_lines[0]}}\\dir" } + large_dword: { raw_value: 4294967295, type: 'REG_DWORD', value: 4294967295 } + large_qword: { raw_value: 18446744073709551615, type: 'REG_QWORD', value: 18446744073709551615 } + multi: { raw_value: ['a, b', 'c'], type: 'REG_MULTI_SZ', value: ['a, b', 'c'] } + qword: { raw_value: 1, type: 'REG_QWORD', value: 1 } + string: { raw_value: 'test', type: 'REG_SZ', value: 'test' } + sub_keys: + - nest1 + - nest2 + +- name: assert get known nested reg key structure + assert: + that: + - actual == expected + +- name: get known reg key with no sub keys but some properties + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\single + register: actual + +- name: set expected value for reg key with no sub keys but some properties + set_fact: + expected: + changed: false + exists: true + failed: false + properties: + none: { raw_value: [], type: 'REG_NONE', value: [] } + none1: { raw_value: ["0x00"], type: 'REG_NONE', value: [0] } + string1: { raw_value: '', type: 'REG_SZ', value: '' } + string2: { raw_value: 'abc123', type: 'REG_SZ', value: 'abc123' } + sub_keys: [] + +- name: assert get known reg key with no sub keys but some properties + assert: + that: + - actual == expected + +- name: get known reg key without sub keys and properties + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\nested\nest2 + register: actual + +- name: set expected value for reg key without sub keys or properties + set_fact: + expected: + changed: false + exists: true + failed: false + properties: {} + sub_keys: [] + register: expected + +- name: assert get known reg key without sub keys and properties + assert: + that: + - actual == expected + +- name: get non-existent reg key + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\Thispathwillneverexist + register: actual + +- name: set expected value for non-existent reg key + set_fact: + expected: + changed: false + exists: false + failed: false + +- name: assert get non-existent reg key + assert: + that: + - actual == expected + +- name: get string property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\nested + name: string + register: actual + +- name: set expected string property + set_fact: + expected: + changed: false + exists: true + failed: false + raw_value: 'test' + type: 'REG_SZ' + value: 'test' + +- name: assert get string property + assert: + that: + - actual == expected + +- name: get expand string property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\nested + name: expand + register: actual + +- name: set expected expand string property + set_fact: + expected: + changed: false + exists: true + failed: false + raw_value: '%windir%\dir' + type: 'REG_EXPAND_SZ' + value: "{{win_dir_value.stdout_lines[0]}}\\dir" + +- name: assert get expand string property + assert: + that: + - actual == expected + +- name: get multi string property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\nested + name: multi + register: actual + +- name: set expected multi string property + set_fact: + expected: + changed: false + exists: true + failed: false + raw_value: ['a, b', 'c'] + type: 'REG_MULTI_SZ' + value: ['a, b', 'c'] + +- name: assert get multi string property + assert: + that: + - actual == expected + +- name: get binary property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\nested + name: binary + register: actual + +- name: set expected binary property + set_fact: + expected: + changed: false + exists: true + failed: false + raw_value: ["0x01", "0x16"] + type: 'REG_BINARY' + value: [1, 22] + +- name: assert get binary property + assert: + that: + - actual == expected + +- name: get dword property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\nested + name: dword + register: actual + +- name: set expected dword property + set_fact: + expected: + changed: false + exists: true + failed: false + raw_value: 1 + type: 'REG_DWORD' + value: 1 + +- name: assert get dword property + assert: + that: + - actual == expected + +- name: get qword property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\nested + name: qword + register: actual + +- name: set expected qword property + set_fact: + expected: + changed: false + exists: true + failed: false + raw_value: 1 + type: 'REG_QWORD' + value: 1 + +- name: assert get qword property + assert: + that: + - actual == expected + +- name: get none property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\single + name: none + register: actual + +- name: set expected none property + set_fact: + expected: + changed: false + exists: true + failed: false + raw_value: [] + type: 'REG_NONE' + value: [] + +- name: assert get none property + assert: + that: + - actual == expected + +- name: get none with value property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\single + name: none1 + register: actual + +- name: set expected none with value property + set_fact: + expected: + changed: false + exists: true + failed: false + raw_value: ["0x00"] + type: 'REG_NONE' + value: [0] + +- name: assert get non with value property + assert: + that: + - actual == expected + +- name: get non-existent property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\single + name: doesnotexist + register: actual + +- name: set expected non-existent property + set_fact: + expected: + changed: false + exists: false + failed: false + +- name: assert get non-existent property + assert: + that: + - actual == expected + +- name: get key with default property set + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\Duplicate Default + register: actual + +- name: assert get key with default property set + assert: + that: + - actual.properties[""]['raw_value'] == "default" + - actual.properties[""]['type'] == "REG_SZ" + - actual.properties[""]['value'] == "default" + - actual.properties['(Default)'].raw_value == "custom" + - actual.properties['(Default)'].type == "REG_SZ" + - actual.properties['(Default)'].value == "custom" + +- name: get default property + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\Duplicate Default + name: '' + register: actual + +- name: assert get default property + assert: + that: + - actual.value == "default" + - actual.raw_value == "default" + - actual.type == "REG_SZ" + +- name: get key with blank property set + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\Blank Default + register: actual + +- name: assert get key with blank property set + assert: + that: + - actual.properties[""].raw_value == "" + - actual.properties[""].type == "REG_SZ" + - actual.properties[""].value == "" + - actual.properties['(Default)'].raw_value == "" + - actual.properties['(Default)'].type == "REG_SZ" + - actual.properties['(Default)'].value == "" + +- name: get default property as empty string + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\Blank Default + name: '' + register: actual + +- name: assert get default property as empty string + assert: + that: + - actual.value == "" + - actual.raw_value == "" + - actual.type == "REG_SZ" + +- name: get key with no properties set + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\Empty Default + register: actual + +- name: assert get key with no properties set + assert: + that: + - actual.properties == {} + +- name: get default property that has not been set + win_reg_stat: + path: HKCU:\{{ test_reg_path }}\Empty Default + name: '' + register: actual + +- name: assert get default property that has not been set + assert: + that: + - not actual.exists diff --git a/test/integration/targets/win_reg_stat/templates/test_reg.reg.j2 b/test/integration/targets/win_reg_stat/templates/test_reg.reg.j2 new file mode 100644 index 0000000000..ac3d44ed73 --- /dev/null +++ b/test/integration/targets/win_reg_stat/templates/test_reg.reg.j2 @@ -0,0 +1,37 @@ +Windows Registry Editor Version 5.00 + +[HKEY_CURRENT_USER\{{ test_reg_path }}] + +[HKEY_CURRENT_USER\{{ test_reg_path }}\nested] +"string"="test" +"binary"=hex:01,16 +"dword"=dword:00000001 +"qword"=hex(b):01,00,00,00,00,00,00,00 +"large_dword"=dword:ffffffff +"large_qword"=hex(b):ff,ff,ff,ff,ff,ff,ff,ff +"multi"=hex(7):61,00,2c,00,20,00,62,00,00,00,63,00,00,00,00,00 +"expand"=hex(2):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,64,00,69,\ + 00,72,00,00,00 + +[HKEY_CURRENT_USER\{{ test_reg_path }}\nested\nest1] +"dontcare"="" + +[HKEY_CURRENT_USER\{{ test_reg_path }}\nested\nest2] + + +[HKEY_CURRENT_USER\{{ test_reg_path }}\single] +"string1"="" +"string2"="abc123" +"none"=hex(0): +"none1"=hex(0):00 + +[HKEY_CURRENT_USER\{{ test_reg_path }}\Empty Default] + + +[HKEY_CURRENT_USER\{{ test_reg_path }}\Blank Default] +@="" +"(Default)"="" + +[HKEY_CURRENT_USER\{{ test_reg_path }}\Duplicate Default] +@="default" +"(Default)"="custom" diff --git a/test/integration/targets/win_regedit/defaults/main.yml b/test/integration/targets/win_regedit/defaults/main.yml index cb3b84b0a1..ec88487556 100644 --- a/test/integration/targets/win_regedit/defaults/main.yml +++ b/test/integration/targets/win_regedit/defaults/main.yml @@ -1,3 +1,3 @@ -test_win_regedit_local_key: HKLM:\Software\Cow Corp +test_win_regedit_local_key: 'HKLM:\Software\Moo []{}!@#$%^&*()-_=+/key''"?<>' test_win_regedit_classes_key: HKCR:\.test-ansible test_win_regedit_hive_key: HKLM:\ANSIBLE\NewKey diff --git a/test/integration/targets/win_regedit/tasks/create_tests.yml b/test/integration/targets/win_regedit/tasks/create_tests.yml index d2e3a38e64..e8cc536774 100644 --- a/test/integration/targets/win_regedit/tasks/create_tests.yml +++ b/test/integration/targets/win_regedit/tasks/create_tests.yml @@ -131,14 +131,6 @@ - data_create_actual.type == test_win_regedit_key_expected_type when: test_win_regedit_key_type not in ['dword', 'qword'] -- name: debug 1 - debug: - var: test_win_regedit_key_expected_value1 - -- name: debug 2 - debug: - var: test_win_regedit_key_expected_value1|int - - name: assert create a {{test_win_regedit_key_type}} for dword or qword assert: that: diff --git a/test/integration/targets/win_regedit/tasks/tests.yml b/test/integration/targets/win_regedit/tasks/tests.yml index d2e89963b4..d633e5333b 100644 --- a/test/integration/targets/win_regedit/tasks/tests.yml +++ b/test/integration/targets/win_regedit/tasks/tests.yml @@ -1,4 +1,17 @@ --- +- name: check warning is fired if path with / as separators is used + win_regedit: + path: HKLM:\SOFTWARE/Microsoft + state: present + register: forward_separator_warn + +- name: assert warning is fired if / is used as a separator + assert: + that: + - forward_separator_warn.deprecations|length == 1 + - forward_separator_warn.deprecations[0].msg == "path is not using '\\' as a separator, support for '/' as a separator will be removed in a future Ansible version" + - forward_separator_warn.deprecations[0].version == 2.12 + - name: fail run win_regedit with larger dword win_regedit: path: '{{test_win_regedit_local_key}}' @@ -82,16 +95,17 @@ register: modify_default_check check_mode: yes -# win_reg_stat struggles with the (Default) property just use powershell - name: get actual modify the (Default) key property check - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue($null, $null)" + win_reg_stat: + path: '{{ test_win_regedit_local_key }}' + name: '' register: modify_default_actual_check - name: assert modify the (Default) key property check assert: that: - modify_default_check is changed - - modify_default_actual_check.stdout == "" + - not modify_default_actual_check.exists - name: modify the (Default) key property win_regedit: @@ -101,14 +115,16 @@ register: modify_default - name: get actual modify the (Default) key property - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue($null, $null)" + win_reg_stat: + path: '{{ test_win_regedit_local_key }}' + name: '' register: modify_default_actual - name: assert modify the (Default) key property assert: that: - modify_default is changed - - modify_default_actual.stdout == "default value\r\n" + - modify_default_actual.value == "default value" - name: create an actual property called (Default) win_regedit: @@ -120,20 +136,17 @@ register: create_specific_default_check check_mode: yes -- name: get actual value for (Default) property to ensure it didn't change check - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue($null, $null)" - register: create_specific_default_actual_default_check - -- name: get actual for create specific property called (Default) check - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue('(Default)', $null)" +- name: get actual value for (Default) property + win_reg_stat: + path: '{{ test_win_regedit_local_key }}' register: create_specific_default_actual_check - name: assert create specific property called (Default) check assert: that: - create_specific_default_check is changed - - create_specific_default_actual_default_check.stdout == "default value\r\n" - - create_specific_default_actual_check.stdout == "" + - create_specific_default_actual_check.properties[""].value == "default value" + - not "(Default)" in create_specific_default_actual_check.properties - name: create an actual property called (Default) win_regedit: @@ -144,20 +157,17 @@ state: present register: create_specific_default -- name: get actual value for (Default) property to ensure it didn't change - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue($null, $null)" - register: create_specific_default_actual_default - -- name: get actual for specific property called (Default) - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue('(Default)', $null)" +- name: get actual value for (Default) property + win_reg_stat: + path: '{{ test_win_regedit_local_key }}' register: create_specific_default_actual - name: assert create specific property called (Default) assert: that: - create_specific_default is changed - - create_specific_default_actual_default.stdout == "default value\r\n" - - create_specific_default_actual.stdout == "custom default value\r\n" + - create_specific_default_actual.properties[""].value == "default value" + - create_specific_default_actual.properties["(Default)"].value == "custom default value" - name: delete property check win_regedit: @@ -219,19 +229,16 @@ check_mode: yes - name: get actual of key's (Default) property check - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue($null, $null)" + win_reg_stat: + path: '{{ test_win_regedit_local_key }}' register: delete_default_actual_check -- name: get actual of custom (Default) property check - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue('(Default)', $null)" - register: delete_default_custom_actual_check - - name: assert delete the key's (Default) property check assert: that: - delete_default_check is changed - - delete_default_actual_check.stdout == "default value\r\n" - - delete_default_custom_actual_check.stdout == "custom default value\r\n" + - delete_default_actual_check.properties[""].value == "default value" + - delete_default_actual_check.properties["(Default)"].value == "custom default value" - name: delete the key's (Default) property win_regedit: @@ -241,19 +248,16 @@ register: delete_default - name: get actual of key's (Default) property - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue($null, $null)" + win_reg_stat: + path: '{{ test_win_regedit_local_key }}' register: delete_default_actual -- name: get actual of custom (Default) property - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue('(Default)', $null)" - register: delete_default_custom_actual - - name: assert delete the key's (Default) property assert: that: - delete_default is changed - - delete_default_actual.stdout == "" - - delete_default_custom_actual.stdout == "custom default value\r\n" + - not "" in delete_default_actual.properties + - delete_default_actual.properties["(Default)"].value == "custom default value" - name: recreate the key's (Default) property for next test win_regedit: @@ -270,19 +274,16 @@ check_mode: yes - name: get actual of key's (Default) property check - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue($null, $null)" + win_reg_stat: + path: '{{ test_win_regedit_local_key }}' register: delete_custom_default_actual_check -- name: get actual of custom (Default) property check - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue('(Default)', $null)" - register: delete_custom_default_custom_actual_check - - name: assert delete the custom (Default) property check assert: that: - delete_custom_default_check is changed - - delete_custom_default_actual_check.stdout == "default value\r\n" - - delete_custom_default_custom_actual_check.stdout == "custom default value\r\n" + - delete_custom_default_actual_check.properties[""].value == "default value" + - delete_custom_default_actual_check.properties["(Default)"].value == "custom default value" - name: delete the custom (Default) property win_regedit: @@ -293,19 +294,16 @@ register: delete_custom_default - name: get actual of key's (Default) property - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue($null, $null)" + win_reg_stat: + path: '{{ test_win_regedit_local_key }}' register: delete_custom_default_actual -- name: get actual of custom (Default) property - win_command: powershell.exe "(Get-Item -Path '{{test_win_regedit_local_key}}').GetValue('(Default)', $null)" - register: delete_custom_default_custom_actual - - name: assert delete the custom (Default) property assert: that: - delete_custom_default is changed - - delete_custom_default_actual.stdout == "default value\r\n" - - delete_custom_default_custom_actual.stdout == "" + - delete_custom_default_actual.properties[""].value == "default value" + - not "(Default)" in delete_custom_default_actual.properties - name: add some nested keys for later deletion win_regedit: @@ -366,6 +364,26 @@ that: - delete_key_again is not changed +- name: create a new key without specifying the property + win_regedit: + path: '{{ test_win_regedit_local_key }}\new' + state: present + register: create_key_no_prop + +- name: get result of create a new key without specifying the property + win_reg_stat: + path: '{{ test_win_regedit_local_key }}\new' + register: create_key_no_prop_actual + +- name: assert create a new key without specifying the property + assert: + that: + - create_key_no_prop is changed + - not create_key_no_prop.data_changed + - not create_key_no_prop.data_type_changed + - create_key_no_prop_actual.exists + - create_key_no_prop_actual.properties == {} + - name: create key in HKEY_CLASSES_ROOT check win_regedit: path: '{{test_win_regedit_classes_key}}' |