From 2f2b10642388992d5b858989efcc0b69f83e22bf Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Mon, 22 Jul 2019 09:12:14 +1000 Subject: [PATCH] Fix win_reg_stat for HKU hives (#59359) --- changelogs/fragments/win_reg_stat-hku.yaml | 2 ++ lib/ansible/modules/windows/win_reg_stat.ps1 | 2 +- .../targets/win_reg_stat/tasks/tests.yml | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/win_reg_stat-hku.yaml diff --git a/changelogs/fragments/win_reg_stat-hku.yaml b/changelogs/fragments/win_reg_stat-hku.yaml new file mode 100644 index 00000000000..5008dd1ef0d --- /dev/null +++ b/changelogs/fragments/win_reg_stat-hku.yaml @@ -0,0 +1,2 @@ +bugfixes: +- win_reg_stat - fix issue when trying to check keys in ``HKU:\`` - https://github.com/ansible/ansible/issues/59337 diff --git a/lib/ansible/modules/windows/win_reg_stat.ps1 b/lib/ansible/modules/windows/win_reg_stat.ps1 index aa7e4ba3147..c31fc5a8693 100644 --- a/lib/ansible/modules/windows/win_reg_stat.ps1 +++ b/lib/ansible/modules/windows/win_reg_stat.ps1 @@ -80,7 +80,7 @@ $registry_hive = switch(Split-Path -Path $path -Qualifier) { "HKCC:" { [Microsoft.Win32.Registry]::CurrentConfig } "HKCU:" { [Microsoft.Win32.Registry]::CurrentUser } "HKLM:" { [Microsoft.Win32.Registry]::LocalMachine } - "HKU" { [Microsoft.Win32.Registry]::Users } + "HKU:" { [Microsoft.Win32.Registry]::Users } } $key = $null diff --git a/test/integration/targets/win_reg_stat/tasks/tests.yml b/test/integration/targets/win_reg_stat/tasks/tests.yml index 285b501a4ad..5424ba4d45b 100644 --- a/test/integration/targets/win_reg_stat/tasks/tests.yml +++ b/test/integration/targets/win_reg_stat/tasks/tests.yml @@ -362,3 +362,16 @@ assert: that: - not actual.exists + +# Tests https://github.com/ansible/ansible/issues/59337 +- name: test out all registry hives + win_reg_stat: + path: '{{ item }}' + register: reg_hive_stat + failed_when: not reg_hive_stat.exists + with_items: + - HKCR:\* + - HKCC:\Software + - HKCU:\Software + - HKLM:\Software + - HKU:\.DEFAULT