Add exception handling to win_domain_controller (#58234)
* Add exception handling to win_domain_controller * Add changelog * Fix PSUseDeclaredVarsMoreThanAssignments * Remove dns domain cannot be resolved error message As requested by PR review in https://github.com/ansible/ansible/pull/58234#discussion_r300509880
This commit is contained in:
parent
cc5957001c
commit
811153afb1
2 changed files with 16 additions and 1 deletions
2
changelogs/fragments/win_domain-exceptions.yaml
Normal file
2
changelogs/fragments/win_domain-exceptions.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- win_domain_controller - Do not fail the play without the user being able to catch dcpromo failing because of a pending reboot within a playbook using ignore_error or retry logic.
|
|
@ -212,7 +212,20 @@ Try {
|
|||
if ($site_name) {
|
||||
$install_params.SiteName = $site_name
|
||||
}
|
||||
Install-ADDSDomainController -NoRebootOnCompletion -Force @install_params
|
||||
try
|
||||
{
|
||||
$null = Install-ADDSDomainController -NoRebootOnCompletion -Force @install_params
|
||||
} catch [Microsoft.DirectoryServices.Deployment.DCPromoExecutionException] {
|
||||
# ExitCode 15 == 'Role change is in progress or this computer needs to be restarted.'
|
||||
# DCPromo exit codes details can be found at https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/deploy/troubleshooting-domain-controller-deployment
|
||||
if ($_.Exception.ExitCode -eq 15) {
|
||||
$result.reboot_required = $true
|
||||
} else {
|
||||
Fail-Json -obj $result -message "Failed to install ADDSDomainController with DCPromo: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
# If $_.FullyQualifiedErrorId -eq 'Test.VerifyUserCredentialPermissions.DCPromo.General.25,Microsoft.DirectoryServices.Deployment.PowerShell.Commands.InstallADDSDomainControllerCommand'
|
||||
# the module failed to resolve the given dns domain name
|
||||
|
||||
Write-DebugLog "Installation complete, trying to start the Netlogon service"
|
||||
# The Netlogon service is set to auto start but is not started. This is
|
||||
|
|
Loading…
Reference in a new issue