From 6039ff9a24bb47ade74b053e72cdf447109c9bbb Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Fri, 12 Apr 2019 14:14:49 +1000 Subject: [PATCH] win_domain - fix for checking for domain on new host (#55195) --- changelogs/fragments/win_domain-setup.yaml | 2 ++ lib/ansible/modules/windows/win_domain.ps1 | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/win_domain-setup.yaml diff --git a/changelogs/fragments/win_domain-setup.yaml b/changelogs/fragments/win_domain-setup.yaml new file mode 100644 index 00000000000..cd285bd4fae --- /dev/null +++ b/changelogs/fragments/win_domain-setup.yaml @@ -0,0 +1,2 @@ +bugfixes: +- win_domain - Fix checking for a domain introduced in a recent patch diff --git a/lib/ansible/modules/windows/win_domain.ps1 b/lib/ansible/modules/windows/win_domain.ps1 index 393c5447db4..a65dbd2b143 100644 --- a/lib/ansible/modules/windows/win_domain.ps1 +++ b/lib/ansible/modules/windows/win_domain.ps1 @@ -74,7 +74,8 @@ try { # Cannot use Get-ADForest as that requires credential delegation, the below does not $forest_context = New-Object -TypeName System.DirectoryServices.ActiveDirectory.DirectoryContext -ArgumentList Forest, $dns_domain_name $forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetForest($forest_context) -} catch [System.DirectoryServices.ActiveDirectory.ActiveDirectoryObjectNotFoundException] { } +} catch [System.DirectoryServices.ActiveDirectory.ActiveDirectoryObjectNotFoundException] { +} catch [System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException] { } if (-not $forest) { $result.changed = $true