From ca42cb286807d75c10a1699bb100492db0d0ebd5 Mon Sep 17 00:00:00 2001 From: philseeley Date: Tue, 12 Nov 2019 15:53:51 +1100 Subject: [PATCH] Make the DNS service optional when installing Active Directory (#63440) * Added install_dns option to the win_domain module. * Added install_dns option to the win_domain_controller module. * Updated version_added to devel branch version 2.10. * Updates for ansible-test errors. * Minor nits to docs --- lib/ansible/modules/windows/win_domain.ps1 | 3 ++- lib/ansible/modules/windows/win_domain.py | 6 ++++++ lib/ansible/modules/windows/win_domain_controller.ps1 | 4 ++++ lib/ansible/modules/windows/win_domain_controller.py | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/windows/win_domain.ps1 b/lib/ansible/modules/windows/win_domain.ps1 index 546799b7063..9f075a0ce3e 100644 --- a/lib/ansible/modules/windows/win_domain.ps1 +++ b/lib/ansible/modules/windows/win_domain.ps1 @@ -34,6 +34,7 @@ $sysvol_path = Get-AnsibleParam -obj $params -name "sysvol_path" -type "path" $create_dns_delegation = Get-AnsibleParam -obj $params -name "create_dns_delegation" -type "bool" $domain_mode = Get-AnsibleParam -obj $params -name "domain_mode" -type "str" $forest_mode = Get-AnsibleParam -obj $params -name "forest_mode" -type "str" +$install_dns = Get-AnsibleParam -obj $params -name "install_dns" -type "bool" -default $true # FUTURE: Support down to Server 2012? if ([System.Environment]::OSVersion.Version -lt [Version]"6.3.9600.0") { @@ -89,7 +90,7 @@ if (-not $forest) { SafeModeAdministratorPassword=$sm_cred; Confirm=$false; SkipPreChecks=$true; - InstallDns=$true; + InstallDns=$install_dns; NoRebootOnCompletion=$true; WhatIf=$check_mode; } diff --git a/lib/ansible/modules/windows/win_domain.py b/lib/ansible/modules/windows/win_domain.py index 730486513ae..54d77104b89 100644 --- a/lib/ansible/modules/windows/win_domain.py +++ b/lib/ansible/modules/windows/win_domain.py @@ -71,6 +71,12 @@ options: type: str choices: [ Win2003, Win2008, Win2008R2, Win2012, Win2012R2, WinThreshold ] version_added: '2.8' + install_dns: + description: + - Whether to install the DNS service when creating the domain controller. + type: bool + default: yes + version_added: '2.10' seealso: - module: win_domain_controller - module: win_domain_computer diff --git a/lib/ansible/modules/windows/win_domain_controller.ps1 b/lib/ansible/modules/windows/win_domain_controller.ps1 index 8d15a5614e3..fe4acea37be 100644 --- a/lib/ansible/modules/windows/win_domain_controller.ps1 +++ b/lib/ansible/modules/windows/win_domain_controller.ps1 @@ -105,6 +105,7 @@ $database_path = Get-AnsibleParam -obj $params -name "database_path" -type "path $sysvol_path = Get-AnsibleParam -obj $params -name "sysvol_path" -type "path" $read_only = Get-AnsibleParam -obj $params -name "read_only" -type "bool" -default $false $site_name = Get-AnsibleParam -obj $params -name "site_name" -type "str" -failifempty $read_only +$install_dns = Get-AnsibleParam -obj $params -name "install_dns" -type "bool" $state = Get-AnsibleParam -obj $params -name "state" -validateset ("domain_controller", "member_server") -failifempty $result @@ -212,6 +213,9 @@ Try { if ($site_name) { $install_params.SiteName = $site_name } + if ($null -ne $install_dns) { + $install_params.InstallDns = $install_dns + } try { $null = Install-ADDSDomainController -NoRebootOnCompletion -Force @install_params diff --git a/lib/ansible/modules/windows/win_domain_controller.py b/lib/ansible/modules/windows/win_domain_controller.py index 8bfd84cb09b..0deaf1135e9 100644 --- a/lib/ansible/modules/windows/win_domain_controller.py +++ b/lib/ansible/modules/windows/win_domain_controller.py @@ -70,6 +70,13 @@ options: - If not set then the default path is C(%SYSTEMROOT%\SYSVOL). type: path version_added: '2.5' + install_dns: + description: + - Whether to install the DNS service when creating the domain controller. + - If not specified then the C(-InstallDns) option is not supplied to C(Install-ADDSDomainController) command, + see U(https://docs.microsoft.com/en-us/powershell/module/addsdeployment/install-addsdomaincontroller). + type: bool + version_added: '2.10' seealso: - module: win_domain - module: win_domain_computer