Debian Codegraph @

ansible_collections/microsoft/ad/tests/integration/targets/domain_child/setup.yml

raw symbols SCIP
1 - name: setup common Windows information
2 hosts: windows
3 gather_facts: no
4
5 tasks:
6 - name: get network connection names
7 ansible.windows.win_powershell:
8 parameters:
9 IPAddress: '{{ ansible_host }}'
10 script: |
11 param ($IPAddress)
12
13 $Ansible.Changed = $false
14
15 Get-CimInstance -ClassName Win32_NetworkAdapter -Filter "Netenabled='True'" |
16 ForEach-Object -Process {
17 $config = Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter "Index='$($_.Index)'"
18 if ($config.IPAddress -contains $IPAddress) {
19 $_.NetConnectionID
20 }
21 }
22 register: connection_name
23
24 - name: create parent forest
25 hosts: PARENT
26 gather_facts: no
27
28 tasks:
29 - name: set the DNS for the internal adapters to localhost
30 ansible.windows.win_dns_client:
31 adapter_names:
32 - '{{ connection_name.output[0] }}'
33 dns_servers:
34 - 127.0.0.1
35
36 - name: ensure domain exists and DC is promoted as a domain controller
37 microsoft.ad.domain:
38 dns_domain_name: '{{ domain_realm }}'
39 safe_mode_password: '{{ domain_password }}'
40 reboot: true
41
42 - name: create parent domain username
43 microsoft.ad.user:
44 name: '{{ domain_username }}'
45 upn: '{{ domain_user_upn }}'
46 description: '{{ domain_username }} Domain Account'
47 password: '{{ domain_password }}'
48 password_never_expires: yes
49 update_password: when_changed
50 groups:
51 add:
52 - Domain Admins
53 - Enterprise Admins
54 state: present
55
56 - name: setup test host
57 hosts: CHILD,TREE
58 gather_facts: no
59
60 tasks:
61 - name: set DNS for the private adapter to point to the parent forest DC
62 ansible.windows.win_dns_client:
63 adapter_names:
64 - '{{ connection_name.output[0] }}'
65 dns_servers:
66 - '{{ hostvars["PARENT"]["ansible_host"] }}'
67
68 - name: install RSAT tools for debugging purposes
69 ansible.windows.win_feature:
70 name: RSAT-AD-PowerShell
71 state: present