diff --git a/lib/ansible/modules/windows/win_regedit.ps1 b/lib/ansible/modules/windows/win_regedit.ps1 index 0e03908bdf2..1ac83efa42c 100644 --- a/lib/ansible/modules/windows/win_regedit.ps1 +++ b/lib/ansible/modules/windows/win_regedit.ps1 @@ -562,6 +562,7 @@ $key_prefix[$path] } finally { if ($hive) { [GC]::Collect() + [GC]::WaitForPendingFinalizers() try { [Ansible.RegistryUtil]::UnloadHive("ANSIBLE") } catch [System.ComponentModel.Win32Exception] { diff --git a/test/integration/targets/win_regedit/aliases b/test/integration/targets/win_regedit/aliases index 2ad273c515a..ee0ed5974e9 100644 --- a/test/integration/targets/win_regedit/aliases +++ b/test/integration/targets/win_regedit/aliases @@ -1,2 +1 @@ windows/ci/group2 -unstable diff --git a/test/integration/targets/win_regedit/tasks/tests.yml b/test/integration/targets/win_regedit/tasks/tests.yml index f42ccfcfe30..d2e89963b40 100644 --- a/test/integration/targets/win_regedit/tasks/tests.yml +++ b/test/integration/targets/win_regedit/tasks/tests.yml @@ -537,7 +537,6 @@ $prop = Get-ItemProperty -Path HKLM:\ANSIBLE\NewKey -Name TestProp -ErrorAction SilentlyContinue if ($prop) { $prop.TestProp - $prop.Close() } ®.exe unload HKLM\ANSIBLE > $null exit 0 @@ -565,7 +564,6 @@ $prop = Get-ItemProperty -Path HKLM:\ANSIBLE\NewKey -Name TestProp -ErrorAction SilentlyContinue if ($prop) { $prop.TestProp - $prop.Close() } ®.exe unload HKLM\ANSIBLE > $null exit 0 @@ -607,7 +605,6 @@ $prop = Get-ItemProperty -Path HKLM:\ANSIBLE\NewKey -Name TestProp -ErrorAction SilentlyContinue if ($prop) { $prop.TestProp - $prop.Close() } ®.exe unload HKLM\ANSIBLE > $null exit 0 @@ -633,7 +630,6 @@ $prop = Get-ItemProperty -Path HKLM:\ANSIBLE\NewKey -Name TestProp -ErrorAction SilentlyContinue if ($prop) { $prop.TestProp - $prop.Close() } ®.exe unload HKLM\ANSIBLE > $null exit 0 @@ -662,7 +658,7 @@ win_regedit: path: '{{test_win_regedit_hive_key}}' state: absent - delete_yes: yes + delete_key: yes hive: C:\Users\Default\NTUSER.dat register: remove_key_in_hive_check check_mode: yes @@ -688,7 +684,7 @@ win_regedit: path: '{{test_win_regedit_hive_key}}' state: absent - delete_yes: yes + delete_key: yes hive: C:\Users\Default\NTUSER.dat register: remove_key_in_hive @@ -713,7 +709,7 @@ win_regedit: path: '{{test_win_regedit_hive_key}}' state: absent - delete_yes: yes + delete_key: yes hive: C:\Users\Default\NTUSER.dat register: remove_key_in_hive_again