diff --git a/lib/ansible/modules/windows/win_regedit.ps1 b/lib/ansible/modules/windows/win_regedit.ps1 index 07dcf1bc9a4..8bcc79c92cf 100644 --- a/lib/ansible/modules/windows/win_regedit.ps1 +++ b/lib/ansible/modules/windows/win_regedit.ps1 @@ -82,14 +82,14 @@ Function Compare-Data { } else { return $false } - } elseif ($ReferenceData -is [string] -or $ReferenceData -is [int]) { - if ($ReferenceData -ceq $DifferenceData) { + } elseif ($ReferenceData -is [object[]]) { + if (@(Compare-Object $ReferenceData $DifferenceData -SyncWindow 0).Length -eq 0) { return $true } else { return $false } - } elseif ($ReferenceData -is [object[]]) { - if (@(Compare-Object $ReferenceData $DifferenceData -SyncWindow 0).Length -eq 0) { + } else { + if ($ReferenceData -ceq $DifferenceData) { return $true } else { return $false diff --git a/test/integration/targets/win_regedit/tasks/main.yml b/test/integration/targets/win_regedit/tasks/main.yml index 5519e25af05..11aa02e3e84 100644 --- a/test/integration/targets/win_regedit/tasks/main.yml +++ b/test/integration/targets/win_regedit/tasks/main.yml @@ -440,6 +440,28 @@ that: - "check72_result.changed == false" +# https://github.com/ansible/ansible/issues/26049 +# module reports change on dword with hex value even with same value +- name: create hex value with prepending 0x + win_regedit: + key: HKCU:\Software\Cow Corp + value: full_hex_dword + data: 0xffffffff + datatype: dword + register: dword_create + +- name: change hex value and report no changes + win_regedit: + key: HKCU:\Software\Cow Corp + value: full_hex_dword + data: 0xffffffff + datatype: dword + register: dword_create_again + +- assert: + that: + - not dword_create_again|changed + # tear down - name: remove registry key used for testing