win_domain: added option to set database and sysvol path (#34333)
* win_domain: added param to set database and sysvol path * fixed up documentation to work with backslashes
This commit is contained in:
parent
dacd4c4a68
commit
38a31d3156
4 changed files with 48 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
'''
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
'''
|
||||
|
|
Loading…
Reference in a new issue