Debian Codegraph @

ansible_collections/microsoft/ad/tests/integration/targets/offline_join/tasks/tests.yml

raw
1 - name: create computer account
2 computer:
3 name: My, Computer
4 state: present
5 sam_account_name: MyComputer
6 register: comp_account
7
8 - set_fact:
9 object_identity: '{{ comp_account.object_guid }}'
10
11 - name: get initial password info
12 object_info:
13 identity: '{{ object_identity }}'
14 properties:
15 - pwdLastSet
16 register: pwd_info
17
18 - name: get blob - check
19 offline_join:
20 name: My, Computer
21 register: blob_check
22 check_mode: true
23
24 - name: get result of get blob - check
25 object_info:
26 identity: '{{ object_identity }}'
27 properties:
28 - pwdLastSet
29 register: blob_check_actual
30
31 - name: assert get blob - check
32 assert:
33 that:
34 - blob_check is changed
35 - blob_check.blob == ''
36 - blob_check_actual.objects[0].pwdLastSet == pwd_info.objects[0].pwdLastSet
37
38 - name: get blob
39 offline_join:
40 name: My, Computer
41 register: blob
42
43 - name: get result of get blob
44 object_info:
45 identity: '{{ object_identity }}'
46 properties:
47 - pwdLastSet
48 register: blob_actual
49
50 - name: assert get blob
51 assert:
52 that:
53 - blob is changed
54 - blob.blob != None
55 - blob.blob != ''
56 - blob_actual.objects[0].pwdLastSet > pwd_info.objects[0].pwdLastSet
57
58 - block:
59 - name: create blob in file
60 offline_join:
61 identity: '{{ object_identity }}'
62 blob_path: C:\Windows\TEMP\ansible-blob
63 provision_root_ca_certs: true
64 register: blob_path
65
66 - name: get pwd result of create blob in file
67 object_info:
68 identity: '{{ object_identity }}'
69 properties:
70 - pwdLastSet
71 register: blob_path_ad_actual
72
73 - name: get path result of create blob in file
74 ansible.windows.win_stat:
75 path: C:\Windows\TEMP\ansible-blob
76 register: blob_path_file_actual
77
78 - name: assert create blob in file
79 assert:
80 that:
81 - blob_path is changed
82 - blob_path.blob == None
83 - blob_path_ad_actual.objects[0].pwdLastSet > blob_actual.objects[0].pwdLastSet
84 - blob_path_file_actual.stat.exists
85
86 - name: create blob in file - idempotent
87 offline_join:
88 identity: '{{ object_identity }}'
89 blob_path: C:\Windows\TEMP\ansible-blob
90 register: blob_path_again
91
92 - name: get pwd result of create blob in file - idempotent
93 object_info:
94 identity: '{{ object_identity }}'
95 properties:
96 - pwdLastSet
97 register: blob_path_ad_actual_again
98
99 - name: get path result of create blob in file - idempotent
100 ansible.windows.win_stat:
101 path: C:\Windows\TEMP\ansible-blob
102 register: blob_path_file_actual_again
103
104 - name: assert create blob in file - idempotent
105 assert:
106 that:
107 - not blob_path_again is changed
108 - blob_path_again.blob == None
109 - blob_path_ad_actual_again.objects[0].pwdLastSet == blob_path_ad_actual.objects[0].pwdLastSet
110 - blob_path_file_actual_again.stat.size == blob_path_file_actual.stat.size
111 - blob_path_file_actual_again.stat.lastwritetime == blob_path_file_actual.stat.lastwritetime
112
113 always:
114 - name: remove temp blob file
115 ansible.windows.win_file:
116 path: C:\Windows\TEMP\ansible-blob
117 state: absent
118
119 - name: move computer object
120 computer:
121 name: My, Computer
122 identity: '{{ object_identity }}'
123 path: CN=Users,{{ setup_domain_info.output[0].defaultNamingContext }}
124
125 - name: fail to find computer outside default path
126 offline_join:
127 name: My, Computer
128 register: fail_find
129 failed_when: '("Failed to find domain computer account ''CN=My\, Computer,CN=Computers," ~ setup_domain_info.output[0].defaultNamingContext) not in fail_find.msg'
130
131 - name: get blob of computer in different path
132 offline_join:
133 name: My, Computer
134 path: CN=Users,{{ setup_domain_info.output[0].defaultNamingContext }}
135 register: blob_ad_path
136
137 - name: get result of get blob of computer in different pth
138 object_info:
139 identity: '{{ object_identity }}'
140 properties:
141 - pwdLastSet
142 register: blob_ad_path_actual
143
144 - name: assert get blob of computer in different path
145 assert:
146 that:
147 - blob_ad_path is changed
148 - blob_ad_path.blob != None
149 - blob_ad_path.blob != ''
150 - blob_ad_path_actual.objects[0].pwdLastSet > blob_path_ad_actual_again.objects[0].pwdLastSet