Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_scheduled_task/tasks/principals.yml

raw
1 ---
2 - name: create test user
3 ansible.windows.win_user:
4 name: '{{test_scheduled_task_user}}'
5 password: '{{test_scheduled_task_pass}}'
6 state: present
7 groups:
8 - Administrators
9
10 - name: task with password principal (check mode)
11 win_scheduled_task:
12 name: '{{test_scheduled_task_name}}'
13 state: present
14 username: '{{test_scheduled_task_user}}'
15 password: '{{test_scheduled_task_pass}}'
16 logon_type: password
17 update_password: no
18 actions:
19 - path: cmd.exe
20 register: task_with_password_check
21 check_mode: yes
22
23 - name: get result of task with password principal (check mode)
24 win_scheduled_task_stat:
25 path: \
26 name: '{{test_scheduled_task_name}}'
27 register: task_with_password_result_check
28
29 - name: assert results of task with password principal (check mode)
30 assert:
31 that:
32 - task_with_password_check is changed
33 - task_with_password_result_check.task_exists == False
34
35 - name: task with password principal
36 win_scheduled_task:
37 name: '{{test_scheduled_task_name}}'
38 state: present
39 username: '{{test_scheduled_task_user}}'
40 password: '{{test_scheduled_task_pass}}'
41 logon_type: password
42 update_password: no
43 actions:
44 - path: cmd.exe
45 register: task_with_password
46
47 - name: get result of task with password principal
48 win_scheduled_task_stat:
49 path: \
50 name: '{{test_scheduled_task_name}}'
51 register: task_with_password_result
52
53 - name: assert results of task with password principal
54 assert:
55 that:
56 - task_with_password is changed
57 - task_with_password_result.task_exists == True
58 - task_with_password_result.principal.group_id == None
59 - task_with_password_result.principal.logon_type == "TASK_LOGON_PASSWORD"
60 - task_with_password_result.principal.run_level == "TASK_RUNLEVEL_LUA"
61 - task_with_password_result.principal.user_id.endswith(test_scheduled_task_user)
62
63 - name: task with password principal (idempotent)
64 win_scheduled_task:
65 name: '{{test_scheduled_task_name}}'
66 state: present
67 username: '{{test_scheduled_task_user}}'
68 password: '{{test_scheduled_task_pass}}'
69 logon_type: password
70 update_password: no
71 actions:
72 - path: cmd.exe
73 register: task_with_password_again
74
75 - name: assert results of task with password principal (idempotent)
76 assert:
77 that:
78 - task_with_password_again is not changed
79
80 - name: task with password principal force pass change
81 win_scheduled_task:
82 name: '{{test_scheduled_task_name}}'
83 state: present
84 username: '{{test_scheduled_task_user}}'
85 password: '{{test_scheduled_task_pass}}'
86 logon_type: password
87 update_password: yes
88 actions:
89 - path: cmd.exe
90 register: task_with_password_force_update
91
92 - name: assert results of task with password principal force pass change
93 assert:
94 that:
95 - task_with_password_force_update is changed
96
97 - name: task with s4u principal (check mode)
98 win_scheduled_task:
99 name: '{{test_scheduled_task_name}}'
100 state: present
101 username: '{{test_scheduled_task_user}}'
102 password: '{{test_scheduled_task_pass}}'
103 logon_type: s4u
104 update_password: no
105 actions:
106 - path: cmd.exe
107 register: task_with_s4u_check
108 check_mode: yes
109
110 - name: get result of task with s4u principal (check mode)
111 win_scheduled_task_stat:
112 path: \
113 name: '{{test_scheduled_task_name}}'
114 register: task_with_s4u_result_check
115
116 - name: assert results of task with s4u principal (check mode)
117 assert:
118 that:
119 - task_with_s4u_check is changed
120 - task_with_s4u_result_check.task_exists == True
121 - task_with_s4u_result_check.principal.group_id == None
122 - task_with_s4u_result_check.principal.logon_type == "TASK_LOGON_PASSWORD"
123 - task_with_s4u_result_check.principal.run_level == "TASK_RUNLEVEL_LUA"
124 - task_with_s4u_result_check.principal.user_id.endswith(test_scheduled_task_user)
125
126 - name: task with s4u principal
127 win_scheduled_task:
128 name: '{{test_scheduled_task_name}}'
129 state: present
130 username: '{{test_scheduled_task_user}}'
131 password: '{{test_scheduled_task_pass}}'
132 logon_type: s4u
133 update_password: no
134 actions:
135 - path: cmd.exe
136 register: task_with_s4u
137
138 - name: get result of task with s4u principal
139 win_scheduled_task_stat:
140 path: \
141 name: '{{test_scheduled_task_name}}'
142 register: task_with_s4u_result
143
144 - name: assert results of task with s4u principal
145 assert:
146 that:
147 - task_with_s4u is changed
148 - task_with_s4u_result.task_exists == True
149 - task_with_s4u_result.principal.group_id == None
150 - task_with_s4u_result.principal.logon_type == "TASK_LOGON_S4U"
151 - task_with_s4u_result.principal.run_level == "TASK_RUNLEVEL_LUA"
152 - task_with_s4u_result.principal.user_id.endswith(test_scheduled_task_user)
153
154 - name: task with s4u principal (idempotent)
155 win_scheduled_task:
156 name: '{{test_scheduled_task_name}}'
157 state: present
158 username: '{{test_scheduled_task_user}}'
159 password: '{{test_scheduled_task_pass}}'
160 logon_type: s4u
161 update_password: no
162 actions:
163 - path: cmd.exe
164 register: task_with_s4u_again
165
166 - name: assert results of task with s4u principal (idempotent)
167 assert:
168 that:
169 - task_with_s4u_again is not changed
170
171 - name: task with interactive principal (check mode)
172 win_scheduled_task:
173 name: '{{test_scheduled_task_name}}'
174 state: present
175 username: '{{test_scheduled_task_user}}'
176 logon_type: interactive_token
177 actions:
178 - path: cmd.exe
179 register: task_with_interactive_check
180 check_mode: yes
181
182 - name: get result of task with interactive principal (check mode)
183 win_scheduled_task_stat:
184 path: \
185 name: '{{test_scheduled_task_name}}'
186 register: task_with_interactive_result_check
187
188 - name: assert results of task with interactive principal (check mode)
189 assert:
190 that:
191 - task_with_interactive_check is changed
192 - task_with_interactive_result_check.task_exists == True
193 - task_with_interactive_result_check.principal.group_id == None
194 - task_with_interactive_result_check.principal.logon_type == "TASK_LOGON_S4U"
195 - task_with_interactive_result_check.principal.run_level == "TASK_RUNLEVEL_LUA"
196 - task_with_interactive_result_check.principal.user_id.endswith(test_scheduled_task_user)
197
198 - name: task with interactive principal
199 win_scheduled_task:
200 name: '{{test_scheduled_task_name}}'
201 state: present
202 username: '{{test_scheduled_task_user}}'
203 logon_type: interactive_token
204 actions:
205 - path: cmd.exe
206 register: task_with_interactive
207
208 - name: get result of task with interactive principal
209 win_scheduled_task_stat:
210 path: \
211 name: '{{test_scheduled_task_name}}'
212 register: task_with_interactive_result
213
214 - name: assert results of task with interactive principal
215 assert:
216 that:
217 - task_with_interactive is changed
218 - task_with_interactive_result.task_exists == True
219 - task_with_interactive_result.principal.group_id == None
220 - task_with_interactive_result.principal.logon_type == "TASK_LOGON_INTERACTIVE_TOKEN"
221 - task_with_interactive_result.principal.run_level == "TASK_RUNLEVEL_LUA"
222 - task_with_interactive_result.principal.user_id.endswith(test_scheduled_task_user)
223
224 - name: task with interactive principal (idempotent)
225 win_scheduled_task:
226 name: '{{test_scheduled_task_name}}'
227 state: present
228 username: '{{test_scheduled_task_user}}'
229 logon_type: interactive_token
230 actions:
231 - path: cmd.exe
232 register: task_with_interactive_again
233
234 - name: assert results of task with interactive principal (idempotent)
235 assert:
236 that:
237 - task_with_interactive_again is not changed
238
239 - name: task with group principal (check mode)
240 win_scheduled_task:
241 name: '{{test_scheduled_task_name}}'
242 state: present
243 group: Administrators
244 logon_type: group
245 actions:
246 - path: cmd.exe
247 register: task_with_group_check
248 check_mode: yes
249
250 - name: get result of task with group principal (check mode)
251 win_scheduled_task_stat:
252 path: \
253 name: '{{test_scheduled_task_name}}'
254 register: task_with_group_result_check
255
256 - name: assert results of task with group principal (check mode)
257 assert:
258 that:
259 - task_with_group_check is changed
260 - task_with_group_result_check.task_exists == True
261 - task_with_group_result_check.principal.group_id == None
262 - task_with_group_result_check.principal.logon_type == "TASK_LOGON_INTERACTIVE_TOKEN"
263 - task_with_group_result_check.principal.run_level == "TASK_RUNLEVEL_LUA"
264 - task_with_group_result_check.principal.user_id.endswith(test_scheduled_task_user)
265
266 - name: task with group principal
267 win_scheduled_task:
268 name: '{{test_scheduled_task_name}}'
269 state: present
270 group: Administrators
271 logon_type: group
272 actions:
273 - path: cmd.exe
274 register: task_with_group
275
276 - name: get result of task with group principal
277 win_scheduled_task_stat:
278 path: \
279 name: '{{test_scheduled_task_name}}'
280 register: task_with_group_result
281
282 - name: assert results of task with group principal
283 assert:
284 that:
285 - task_with_group is changed
286 - task_with_group_result.task_exists == True
287 - task_with_group_result.principal.group_id == "BUILTIN\\Administrators"
288 - task_with_group_result.principal.logon_type == "TASK_LOGON_GROUP"
289 - task_with_group_result.principal.run_level == "TASK_RUNLEVEL_LUA"
290 - task_with_group_result.principal.user_id == None
291
292 - name: task with group principal (idempotent)
293 win_scheduled_task:
294 name: '{{test_scheduled_task_name}}'
295 state: present
296 group: Administrators
297 logon_type: group
298 actions:
299 - path: cmd.exe
300 register: task_with_group_again
301
302 - name: assert results of task with group principal (idempotent)
303 assert:
304 that:
305 - task_with_group_again is not changed
306
307 - name: task with service account principal (check mode)
308 win_scheduled_task:
309 name: '{{test_scheduled_task_name}}'
310 state: present
311 username: System
312 logon_type: service_account
313 action:
314 - path: cmd.exe
315 register: task_with_service_check
316 check_mode: yes
317
318 - name: get result of task with service account principal (check mode)
319 win_scheduled_task_stat:
320 path: \
321 name: '{{test_scheduled_task_name}}'
322 register: task_with_service_result_check
323
324 - name: assert results of task with service account principal (check mode)
325 assert:
326 that:
327 - task_with_service_check is changed
328 - task_with_service_result_check.task_exists == True
329 - task_with_service_result_check.principal.group_id == "BUILTIN\\Administrators"
330 - task_with_service_result_check.principal.logon_type == "TASK_LOGON_GROUP"
331 - task_with_service_result_check.principal.run_level == "TASK_RUNLEVEL_LUA"
332 - task_with_service_result_check.principal.user_id == None
333
334 - name: task with service account principal
335 win_scheduled_task:
336 name: '{{test_scheduled_task_name}}'
337 state: present
338 username: System
339 logon_type: service_account
340 action:
341 - path: cmd.exe
342 register: task_with_service
343
344 - name: get result of task with service account principal
345 win_scheduled_task_stat:
346 path: \
347 name: '{{test_scheduled_task_name}}'
348 register: task_with_service_result
349
350 - name: assert results of task with service account principal
351 assert:
352 that:
353 - task_with_service is changed
354 - task_with_service_result.task_exists == True
355 - task_with_service_result.principal.group_id == None
356 - task_with_service_result.principal.logon_type == "TASK_LOGON_SERVICE_ACCOUNT"
357 - task_with_service_result.principal.run_level == "TASK_RUNLEVEL_LUA"
358 - task_with_service_result.principal.user_id == "NT AUTHORITY\\SYSTEM"
359
360 - name: task with service account principal (idempotent)
361 win_scheduled_task:
362 name: '{{test_scheduled_task_name}}'
363 state: present
364 username: System
365 logon_type: service_account
366 action:
367 - path: cmd.exe
368 register: task_with_service_again
369
370 - name: assert results of task with service account principal (idempotent)
371 assert:
372 that:
373 - task_with_service_again is not changed
374
375 - name: task with highest privilege (check mode)
376 win_scheduled_task:
377 name: '{{test_scheduled_task_name}}'
378 state: present
379 run_level: highest
380 username: System
381 logon_type: service_account
382 action:
383 - path: cmd.exe
384 register: task_with_highest_privilege_check
385 check_mode: yes
386
387 - name: get result of task with highest privilege (check mode)
388 win_scheduled_task_stat:
389 path: \
390 name: '{{test_scheduled_task_name}}'
391 register: task_with_highest_privilege_result_check
392
393 - name: assert results of task with highest privilege (check mode)
394 assert:
395 that:
396 - task_with_highest_privilege_check is changed
397 - task_with_highest_privilege_result_check.principal.run_level == "TASK_RUNLEVEL_LUA"
398
399 - name: task with highest privilege
400 win_scheduled_task:
401 name: '{{test_scheduled_task_name}}'
402 state: present
403 run_level: highest
404 username: System
405 logon_type: service_account
406 action:
407 - path: cmd.exe
408 register: task_with_highest_privilege
409
410 - name: get result of task with highest privilege
411 win_scheduled_task_stat:
412 path: \
413 name: '{{test_scheduled_task_name}}'
414 register: task_with_highest_privilege_result
415
416 - name: assert results of task with highest privilege
417 assert:
418 that:
419 - task_with_highest_privilege is changed
420 - task_with_highest_privilege_result.principal.run_level == "TASK_RUNLEVEL_HIGHEST"
421
422 - name: task with highest privilege (idempotent)
423 win_scheduled_task:
424 name: '{{test_scheduled_task_name}}'
425 state: present
426 run_level: highest
427 username: System
428 logon_type: service_account
429 action:
430 - path: cmd.exe
431 register: task_with_highest_privilege_again
432
433 - name: assert results of task with highest privilege (idempotent)
434 assert:
435 that:
436 - task_with_highest_privilege_again is not changed