diff --git a/lib/ansible/modules/windows/win_domain.ps1 b/lib/ansible/modules/windows/win_domain.ps1 index 99243e484f4..d43a8661104 100644 --- a/lib/ansible/modules/windows/win_domain.ps1 +++ b/lib/ansible/modules/windows/win_domain.ps1 @@ -39,6 +39,8 @@ $parsed_args = Parse-Args $args -supports_check_mode $true $check_mode = Get-AnsibleParam $parsed_args "_ansible_check_mode" -default $false $dns_domain_name = Get-AnsibleParam $parsed_args "dns_domain_name" -failifempty $true $safe_mode_admin_password = Get-AnsibleParam $parsed_args "safe_mode_password" -failifempty $true +$database_path = Get-AnsibleParam $parsed_args "database_path" -type "path" +$sysvol_path = Get-AnsibleParam $parsed_args "sysvol_path" -type "path" $forest = $null @@ -72,6 +74,12 @@ If(-not $forest) { InstallDNS=$true; NoRebootOnCompletion=$true; } + if ($database_path) { + $install_forest_args.DatabasePath = $database_path + } + if ($sysvol_path) { + $install_forest_args.SysvolPath = $sysvol_path + } $iaf = Install-ADDSForest @install_forest_args diff --git a/lib/ansible/modules/windows/win_domain.py b/lib/ansible/modules/windows/win_domain.py index 2378fb3c864..d0914287c69 100644 --- a/lib/ansible/modules/windows/win_domain.py +++ b/lib/ansible/modules/windows/win_domain.py @@ -23,7 +23,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', 'supported_by': 'core'} -DOCUMENTATION = ''' +DOCUMENTATION = r''' module: win_domain short_description: Ensures the existence of a Windows domain. version_added: 2.3 @@ -39,6 +39,18 @@ options: description: - safe mode password for the domain controller required: true + database_path: + description: + - The path to a directory on a fixed disk of the Windows host where the + domain database will be created. + - If not set then the default path is C(%SYSTEMROOT%\NTDS). + version_added: '2.5' + sysvol_path: + description: + - The path to a directory on a fixed disk of the Windows host where the + Sysvol file will be created. + - If not set then the default path is C(%SYSTEMROOT%\SYSVOL). + version_added: '2.5' author: - Matt Davis (@nitzmahone) ''' diff --git a/lib/ansible/modules/windows/win_domain_controller.ps1 b/lib/ansible/modules/windows/win_domain_controller.ps1 index 57002787ead..e25e0d11eb0 100644 --- a/lib/ansible/modules/windows/win_domain_controller.ps1 +++ b/lib/ansible/modules/windows/win_domain_controller.ps1 @@ -116,6 +116,8 @@ $safe_mode_password= Get-AnsibleParam $param "safe_mode_password" $domain_admin_user = Get-AnsibleParam $param "domain_admin_user" -failifempty $result $domain_admin_password= Get-AnsibleParam $param "domain_admin_password" -failifempty $result $local_admin_password= Get-AnsibleParam $param "local_admin_password" +$database_path = Get-AnsibleParam $param "database_path" -type "path" +$sysvol_path = Get-AnsibleParam $param "sysvol_path" -type "path" $state = Get-AnsibleParam $param "state" -validateset ("domain_controller", "member_server") -failifempty $result $log_path = Get-AnsibleParam $param "log_path" @@ -203,8 +205,18 @@ Try { $safe_mode_secure = $safe_mode_password | ConvertTo-SecureString -AsPlainText -Force Write-DebugLog "Installing domain controller..." - - $install_result = Install-ADDSDomainController -NoRebootOnCompletion -DomainName $dns_domain_name -Credential $domain_admin_cred -SafeModeAdministratorPassword $safe_mode_secure -Force + $install_params = @{ + DomainName = $dns_domain_name + Credential = $domain_admin_cred + SafeModeAdministratorPassword = $safe_mode_secure + } + if ($database_path) { + $install_params.DatabasePath = $database_path + } + if ($sysvol_path) { + $install_params.SysvolPath = $sysvol_path + } + $install_result = Install-ADDSDomainController -NoRebootOnCompletion -Force @install_params Write-DebugLog "Installation completed, needs reboot..." } @@ -252,4 +264,3 @@ Catch { Throw } - diff --git a/lib/ansible/modules/windows/win_domain_controller.py b/lib/ansible/modules/windows/win_domain_controller.py index 6702f1bc2fb..20116b7484f 100644 --- a/lib/ansible/modules/windows/win_domain_controller.py +++ b/lib/ansible/modules/windows/win_domain_controller.py @@ -23,7 +23,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', 'supported_by': 'core'} -DOCUMENTATION = ''' +DOCUMENTATION = r''' module: win_domain_controller short_description: Manage domain controller/member server state for a Windows host version_added: 2.3 @@ -54,6 +54,18 @@ options: choices: - domain_controller - member_server + database_path: + description: + - The path to a directory on a fixed disk of the Windows host where the + domain database will be created.. + - If not set then the default path is C(%SYSTEMROOT%\NTDS). + version_added: '2.5' + sysvol_path: + description: + - The path to a directory on a fixed disk of the Windows host where the + Sysvol folder will be created. + - If not set then the default path is C(%SYSTEMROOT%\SYSVOL). + version_added: '2.5' author: - Matt Davis (@nitzmahone) '''