Debian Codegraph @

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

raw symbols SCIP
1 - name: ensure time is in sync
2 hosts: windows
3 gather_facts: false
4 tasks:
5 - name: get current host datetime
6 command: date +%s
7 changed_when: False
8 delegate_to: localhost
9 run_once: True
10 register: local_time
11
12 - name: set datetime on Windows
13 ansible.windows.win_powershell:
14 parameters:
15 SecondsSinceEpoch: '{{ local_time.stdout | trim }}'
16 script: |
17 param($SecondsSinceEpoch)
18
19 $utc = [System.DateTimeKind]::Utc
20 $epoch = New-Object -TypeName System.DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0, $utc
21 $date = $epoch.AddSeconds($SecondsSinceEpoch)
22
23 Set-Date -Date $date
24
25 - name: set common test vars
26 ansible.builtin.set_fact:
27 get_role_script: |
28 $Ansible.Changed = $false
29 Get-CimInstance -ClassName Win32_ComputerSystem -Property Domain, DomainRole, PartOfDomain |
30 Select-Object -Property @{
31 N = 'Domain'
32 E = {
33 if ($_.PartOfDomain) {
34 $_.Domain
35 }
36 else {
37 $null
38 }
39 }
40 }, @{
41 N = 'DomainRole'
42 E = {
43 switch ($_.DomainRole) {
44 0 { "StandaloneWorkstation" }
45 1 { "MemberWorkstation" }
46 2 { "StandaloneServer" }
47 3 { "MemberServer" }
48 4 { "BackupDC" }
49 5 { "PrimaryDC" }
50 }
51 }
52 }, @{
53 N = 'HostName'
54 E = { $env:COMPUTERNAME }
55 }
56
57 - name: run microsoft.ad.domain_child child tests
58 hosts: CHILD
59 gather_facts: false
60
61 tasks:
62 - name: check domain status to see if test will run
63 ansible.windows.win_powershell:
64 script: '{{ get_role_script }}'
65 register: domain_status
66
67 - ansible.builtin.include_tasks: tasks/main_child.yml
68 when: domain_status.output[0].Domain != child_domain_name
69
70 - name: run microsoft.ad.domain_child tree tests
71 hosts: TREE
72 gather_facts: false
73
74 tasks:
75 - name: check domain status to see if test will run
76 ansible.windows.win_powershell:
77 script: '{{ get_role_script }}'
78 register: domain_status
79
80 - ansible.builtin.include_tasks: tasks/main_tree.yml
81 when: domain_status.output[0].Domain != child_domain_name
82
83 - name: run extra tests to test out cross domain functionality in other modules
84 hosts: localhost
85 gather_facts: false
86
87 tasks:
88 - name: create test OU in each domain
89 microsoft.ad.ou:
90 name: Ansible-{{ item }}
91 state: present
92 delegate_to: '{{ item }}'
93 register: ou_info
94 loop:
95 - PARENT
96 - CHILD
97
98 - block:
99 - name: set facts for each OU DN
100 ansible.builtin.set_fact:
101 parent_ou: '{{ ou_info.results[0].distinguished_name }}'
102 child_ou: '{{ ou_info.results[1].distinguished_name }}'
103
104 - name: create test users
105 microsoft.ad.user:
106 name: User-{{ item }}
107 state: present
108 password: '{{ domain_password }}'
109 path: '{{ {"PARENT": parent_ou, "CHILD": child_ou}[item] }}'
110 register: user_info
111 delegate_to: '{{ item }}'
112 loop:
113 - PARENT
114 - CHILD
115
116 - name: create test groups
117 microsoft.ad.group:
118 name: Group-{{ item }}
119 state: present
120 path: '{{ {"PARENT": parent_ou, "CHILD": child_ou}[item] }}'
121 scope: universal
122 register: group_info
123 delegate_to: '{{ item }}'
124 loop:
125 - PARENT
126 - CHILD
127
128 - name: set facts for each test user and group DN
129 ansible.builtin.set_fact:
130 parent_user: '{{ user_info.results[0].distinguished_name }}'
131 parent_group: '{{ group_info.results[0].distinguished_name }}'
132 child_user: '{{ user_info.results[1].distinguished_name }}'
133 child_group: '{{ group_info.results[1].distinguished_name }}'
134
135 - name: run cross domain tests
136 ansible.builtin.import_tasks: tasks/cross_domain.yml
137
138 always:
139 - name: remove test OU in each domain
140 microsoft.ad.ou:
141 name: Ansible-{{ item }}
142 state: absent
143 delegate_to: '{{ item }}'
144 loop:
145 - PARENT
146 - CHILD