| 1 |
# Copyright (c) 2024 Ansible Project |
| 2 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 3 |
|
| 4 |
DOCUMENTATION: |
| 5 |
module: domain_child |
| 6 |
short_description: Manage domain children in an existing Active Directory forest. |
| 7 |
description: |
| 8 |
- Ensure that a Windows Server host is configured as a domain controller as |
| 9 |
a new domain in an existing forest. |
| 10 |
- This module may require subsequent use of the |
| 11 |
M(ansible.windows.win_reboot) action if changes are made. |
| 12 |
- This module will only check if the domain specified by I(dns_domain_name) |
| 13 |
exists or not. If the domain already exists under the same name, no other |
| 14 |
options, other than the domain name will be checked during the run. |
| 15 |
version_added: 1.6.0 |
| 16 |
options: |
| 17 |
create_dns_delegation: |
| 18 |
description: |
| 19 |
- Whether to create a DNS delegation that references the new DNS |
| 20 |
server that was installed. |
| 21 |
- Valid for Active Directory-integrated DNS only. |
| 22 |
- The default is computed automatically based on the environment. |
| 23 |
type: bool |
| 24 |
database_path: |
| 25 |
description: |
| 26 |
- The path to a directory on a fixed disk of the Windows host where the |
| 27 |
domain database will be created.. |
| 28 |
- If not set then the default path is C(%SYSTEMROOT%\NTDS). |
| 29 |
type: path |
| 30 |
dns_domain_name: |
| 31 |
description: |
| 32 |
- The full DNS name of the domain to create. |
| 33 |
- When I(domain_type=child), the parent DNS domain name is derived |
| 34 |
from this value. |
| 35 |
type: str |
| 36 |
domain_admin_password: |
| 37 |
description: |
| 38 |
- Password for the specified I(domain_admin_user). |
| 39 |
type: str |
| 40 |
required: true |
| 41 |
domain_admin_user: |
| 42 |
description: |
| 43 |
- Username of a domain admin for the parent domain. |
| 44 |
type: str |
| 45 |
required: true |
| 46 |
domain_mode: |
| 47 |
description: |
| 48 |
- Specifies the domain functional level of child/tree. |
| 49 |
- The domain functional level cannot be lower than the forest |
| 50 |
functional level, but it can be higher. |
| 51 |
- The default is automatically computed and set. |
| 52 |
- Current known modes are C(Win2003), C(Win2008), C(Win2008R2), |
| 53 |
C(Win2012), C(Win2012R2), C(WinThreshold), or C(Win2025). |
| 54 |
type: str |
| 55 |
domain_type: |
| 56 |
description: |
| 57 |
- Specifies the type of domain to create. |
| 58 |
- Set to C(child) to create a child of an existing domain as specified |
| 59 |
by I(dns_domain_name). |
| 60 |
- Set to C(tree) to create a new domain tree in an existing forest as |
| 61 |
specified by I(parent_domain_name). The I(dns_domain_name) must be |
| 62 |
the full domain name of the new domain tree to create. |
| 63 |
choices: |
| 64 |
- child |
| 65 |
- tree |
| 66 |
default: child |
| 67 |
type: str |
| 68 |
install_dns: |
| 69 |
description: |
| 70 |
- Whether to install the DNS service when creating the domain |
| 71 |
controller. |
| 72 |
- If not specified then the C(-InstallDns) option is not supplied to |
| 73 |
the C(Install-ADDSDomain) command, see |
| 74 |
L(Install-ADDSDomain,https://learn.microsoft.com/en-us/powershell/module/addsdeployment/install-addsdomain#-installdns) |
| 75 |
for more information. |
| 76 |
type: bool |
| 77 |
log_path: |
| 78 |
description: |
| 79 |
- Specified the fully qualified, non-UNC path to a directory on a fixed |
| 80 |
disk of the local computer that will contain the domain log files. |
| 81 |
type: path |
| 82 |
parent_domain_name: |
| 83 |
description: |
| 84 |
- The fully qualified domain name of an existing parent domain to |
| 85 |
create a new domain tree in. |
| 86 |
- This can only be set when I(domain_type=tree). |
| 87 |
type: str |
| 88 |
replication_source_dc: |
| 89 |
description: |
| 90 |
- Specifies the name of an existing domain controller in the forest that |
| 91 |
will be used as the replication source for the new domain. |
| 92 |
type: str |
| 93 |
version_added: 1.8.0 |
| 94 |
safe_mode_password: |
| 95 |
description: |
| 96 |
- Safe mode password for the domain controller. |
| 97 |
required: true |
| 98 |
type: str |
| 99 |
site_name: |
| 100 |
description: |
| 101 |
- Specifies the name of an existing site where you can place the new |
| 102 |
domain controller. |
| 103 |
type: str |
| 104 |
sysvol_path: |
| 105 |
description: |
| 106 |
- The path to a directory on a fixed disk of the Windows host where the |
| 107 |
Sysvol folder will be created. |
| 108 |
- If not set then the default path is C(%SYSTEMROOT%\SYSVOL). |
| 109 |
type: path |
| 110 |
notes: |
| 111 |
- It is highly recommended to set I(reboot=true) to have Ansible manage the |
| 112 |
host reboot phase as the actions done by this module puts the host in a |
| 113 |
state where it may not be possible for Ansible to reconnect in a |
| 114 |
subsequent task without a reboot. |
| 115 |
- This module must be run on a Windows target host. |
| 116 |
- If using I(reboot=true), multiple reboots may occur if the host required |
| 117 |
a reboot before the domain promotion. |
| 118 |
extends_documentation_fragment: |
| 119 |
- ansible.builtin.action_common_attributes |
| 120 |
- ansible.builtin.action_common_attributes.flow |
| 121 |
- microsoft.ad.action_reboot |
| 122 |
attributes: |
| 123 |
check_mode: |
| 124 |
support: full |
| 125 |
diff_mode: |
| 126 |
support: none |
| 127 |
platform: |
| 128 |
platforms: |
| 129 |
- windows |
| 130 |
action: |
| 131 |
support: full |
| 132 |
async: |
| 133 |
support: partial |
| 134 |
details: Supported for all scenarios except with I(reboot=True). |
| 135 |
bypass_host_loop: |
| 136 |
support: none |
| 137 |
seealso: |
| 138 |
- module: microsoft.ad.domain |
| 139 |
- module: microsoft.ad.domain_controller |
| 140 |
author: |
| 141 |
- Jordan Borean (@jborean93) |
| 142 |
|
| 143 |
EXAMPLES: | |
| 144 |
- name: Create a child domain foo.example.com with parent example.com |
| 145 |
microsoft.ad.domain_child: |
| 146 |
dns_domain_name: foo.example.com |
| 147 |
domain_admin_user: [email protected] |
| 148 |
domain_admin_password: password123! |
| 149 |
safe_mode_password: password123! |
| 150 |
reboot: true |
| 151 |
|
| 152 |
- name: Create a domain tree foo.example.com with parent bar.example.com |
| 153 |
microsoft.ad.domain_child: |
| 154 |
dns_domain_name: foo.example.com |
| 155 |
parent_domain_name: bar.example.com |
| 156 |
domain_type: tree |
| 157 |
domain_admin_user: [email protected] |
| 158 |
domain_admin_password: password123! |
| 159 |
local_admin_password: password123! |
| 160 |
reboot: true |
| 161 |
|
| 162 |
# This scenario is not recommended, use reboot: true when possible |
| 163 |
- name: Promote server with custom paths with manual reboot task |
| 164 |
microsoft.ad.domain_child: |
| 165 |
dns_domain_name: foo.ansible.vagrant |
| 166 |
domain_admin_user: [email protected] |
| 167 |
domain_admin_password: password123! |
| 168 |
safe_mode_password: password123! |
| 169 |
sysvol_path: D:\SYSVOL |
| 170 |
database_path: D:\NTDS |
| 171 |
log_path: D:\NTDS |
| 172 |
register: dc_promotion |
| 173 |
|
| 174 |
- name: Reboot after promotion |
| 175 |
microsoft.ad.win_reboot: |
| 176 |
when: dc_promotion.reboot_required |
| 177 |
|
| 178 |
RETURN: |
| 179 |
reboot_required: |
| 180 |
description: True if changes were made that require a reboot. |
| 181 |
returned: always |
| 182 |
type: bool |
| 183 |
sample: true |