Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_iis_webapppool/tasks/tests.yml

raw
1 ---
2 - name: create default pool check
3 win_iis_webapppool:
4 name: '{{test_iis_webapppool_name}}'
5 state: started
6 register: create_default_check
7 check_mode: yes
8
9 - name: get actual of create default pool check
10 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}"
11 register: create_default_actual_check
12 failed_when: False
13
14 - name: assert create default pool check
15 assert:
16 that:
17 - create_default_check is changed
18 - create_default_actual_check.rc == 1
19
20 - name: create default pool
21 win_iis_webapppool:
22 name: '{{test_iis_webapppool_name}}'
23 state: present
24 register: create_default
25
26 - name: get actual of create default pool
27 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}"
28 register: create_default_actual
29 failed_when: False
30
31 - name: assert create default pool
32 assert:
33 that:
34 - create_default is changed
35 - create_default.info.attributes.name == test_iis_webapppool_name
36 - create_default.info.attributes.startMode == 'OnDemand'
37 - create_default.info.attributes.state == 'Started'
38 - create_default_actual.rc == 0
39
40 - name: change attributes of pool check
41 win_iis_webapppool:
42 name: '{{test_iis_webapppool_name}}'
43 state: present
44 attributes:
45 managedPipelineMode: 1 # Using an enum value
46 cpu.limit: 95 # Nested values
47 processModel.identityType: LocalSystem # Using an enum name
48 processModel.loadUserProfile: True
49 register: change_pool_attributes_check
50 check_mode: yes
51
52 - name: assert change attributes of pool check
53 assert:
54 that:
55 - change_pool_attributes_check is changed
56 - change_pool_attributes_check.info == create_default.info
57
58 - name: change attributes of pool
59 win_iis_webapppool:
60 name: '{{test_iis_webapppool_name}}'
61 state: present
62 attributes:
63 managedPipelineMode: 1 # Using an enum value
64 cpu.limit: 95 # Nested values
65 processModel.identityType: LocalSystem # Using an enum name
66 processModel.loadUserProfile: True
67 test: True
68 register: change_pool_attributes
69
70 - name: assert change attributes of pool
71 assert:
72 that:
73 - change_pool_attributes is changed
74 - change_pool_attributes.info.attributes.managedPipelineMode == 'Classic'
75 - change_pool_attributes.info.cpu.limit == 95
76 - change_pool_attributes.info.processModel.identityType == 'LocalSystem'
77 - change_pool_attributes.info.processModel.loadUserProfile == True
78
79 - name: change attributes of pool again
80 win_iis_webapppool:
81 name: '{{test_iis_webapppool_name}}'
82 state: present
83 attributes:
84 managedPipelineMode: 1 # Using an enum value
85 cpu.limit: 95 # Nested values
86 processModel.identityType: LocalSystem # Using an enum name
87 processModel.loadUserProfile: True
88 register: change_pool_attributes_again
89
90 - name: assert change attributes of pool again
91 assert:
92 that:
93 - change_pool_attributes_again is not changed
94 - change_pool_attributes_again.info == change_pool_attributes.info
95
96 - name: change more complex variables check
97 win_iis_webapppool:
98 name: '{{test_iis_webapppool_name}}'
99 state: present
100 attributes:
101 queueLength: 500
102 recycling.periodicRestart.requests: 10 # Deeply nested attribute
103 recycling.periodicRestart.time: "00:00:05:00.000000" # Timespan with string
104 processModel.pingResponseTime: "00:03:00" # Timespan without days or milliseconds
105 register: change_complex_attributes_check
106 check_mode: yes
107
108 - name: assert change more complex variables check
109 assert:
110 that:
111 - change_complex_attributes_check is changed
112 - change_complex_attributes_check.info == change_pool_attributes_again.info
113
114 - name: change more complex variables
115 win_iis_webapppool:
116 name: '{{test_iis_webapppool_name}}'
117 state: present
118 attributes:
119 queueLength: 500
120 recycling.periodicRestart.requests: 10 # Deeply nested attribute
121 recycling.periodicRestart.time: "00:00:05:00.000000" # Timespan with string
122 processModel.pingResponseTime: "00:03:00" # Timespan without days or milliseconds
123 register: change_complex_attributes
124
125 - name: assert change more complex variables
126 assert:
127 that:
128 - change_complex_attributes is changed
129 - change_complex_attributes.info.attributes.queueLength == 500
130 - change_complex_attributes.info.recycling.periodicRestart.requests == 10
131 - change_complex_attributes.info.recycling.periodicRestart.time.TotalSeconds == 300
132 - change_complex_attributes.info.processModel.pingResponseTime.TotalSeconds == 180
133
134 - name: change more complex variables again
135 win_iis_webapppool:
136 name: '{{test_iis_webapppool_name}}'
137 state: present
138 attributes:
139 queueLength: 500
140 recycling.periodicRestart.requests: 10 # Deeply nested attribute
141 recycling.periodicRestart.time: "00:00:05:00.000000" # Timespan with string
142 processModel.pingResponseTime: "00:03:00" # Timespan without days or milliseconds
143 register: change_complex_attributes_again
144
145 - name: assert change more complex variables again
146 assert:
147 that:
148 - change_complex_attributes_again is not changed
149 - change_complex_attributes_again.info == change_complex_attributes.info
150
151 - name: stop web pool check
152 win_iis_webapppool:
153 name: '{{test_iis_webapppool_name}}'
154 state: stopped
155 register: stop_pool_check
156 check_mode: yes
157
158 - name: get actual status of pool check
159 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
160 register: stop_pool_actual_check
161
162 - name: assert stop web pool check
163 assert:
164 that:
165 - stop_pool_check is changed
166 - stop_pool_actual_check.stdout == 'Started\r\n'
167
168 - name: stop web pool
169 win_iis_webapppool:
170 name: '{{test_iis_webapppool_name}}'
171 state: stopped
172 register: stop_pool
173
174 - name: get actual status of pool
175 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
176 register: stop_pool_actual
177
178 - name: assert stop web pool
179 assert:
180 that:
181 - stop_pool is changed
182 - stop_pool_actual.stdout == 'Stopped\r\n'
183
184 - name: stop web pool again
185 win_iis_webapppool:
186 name: '{{test_iis_webapppool_name}}'
187 state: stopped
188 register: stop_pool_again
189
190 - name: get actual status of pool again
191 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
192 register: stop_pool_actual_again
193
194 - name: assert stop web pool again
195 assert:
196 that:
197 - stop_pool_again is not changed
198 - stop_pool_actual_again.stdout == 'Stopped\r\n'
199
200 - name: start web pool check
201 win_iis_webapppool:
202 name: '{{test_iis_webapppool_name}}'
203 state: started
204 register: start_pool_check
205 check_mode: yes
206
207 - name: get actual status of pool check
208 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
209 register: start_pool_actual_check
210
211 - name: assert start web pool check
212 assert:
213 that:
214 - start_pool_check is changed
215 - start_pool_actual_check.stdout == 'Stopped\r\n'
216
217 - name: start web pool
218 win_iis_webapppool:
219 name: '{{test_iis_webapppool_name}}'
220 state: started
221 register: start_pool
222
223 - name: get actual status of pool
224 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
225 register: start_pool_actual
226
227 - name: assert start web pool
228 assert:
229 that:
230 - start_pool is changed
231 - start_pool_actual.stdout == 'Started\r\n'
232
233 - name: start web pool again
234 win_iis_webapppool:
235 name: '{{test_iis_webapppool_name}}'
236 state: started
237 register: start_pool_again
238
239 - name: get actual status of pool again
240 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
241 register: start_pool_actual_again
242
243 - name: assert start web pool again
244 assert:
245 that:
246 - start_pool_again is not changed
247 - start_pool_actual_again.stdout == 'Started\r\n'
248
249 - name: restart web pool
250 win_iis_webapppool:
251 name: '{{test_iis_webapppool_name}}'
252 state: restarted
253 register: restart_pool
254
255 - name: get actual status of pool
256 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
257 register: restart_pool_actual
258
259 - name: assert restart web pool
260 assert:
261 that:
262 - restart_pool is changed
263 - restart_pool_actual.stdout == 'Started\r\n'
264
265 - name: stop pool before restart on stop test
266 win_iis_webapppool:
267 name: '{{test_iis_webapppool_name}}'
268 state: stopped
269
270 - name: restart from stopped web pool check
271 win_iis_webapppool:
272 name: '{{test_iis_webapppool_name}}'
273 state: restarted
274 register: restart_from_stop_pool_check
275 check_mode: yes
276
277 - name: get actual status of pool check
278 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
279 register: restart_from_stop_pool_actual_check
280
281 - name: assert restart from stopped web pool check
282 assert:
283 that:
284 - restart_from_stop_pool_check is changed
285 - restart_from_stop_pool_actual_check.stdout == 'Stopped\r\n'
286
287 - name: restart from stopped web pool
288 win_iis_webapppool:
289 name: '{{test_iis_webapppool_name}}'
290 state: restarted
291 register: restart_from_stop_pool
292
293 - name: get actual status of pool
294 ansible.windows.win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state"
295 register: restart_from_stop_pool_actual
296
297 - name: assert restart from stopped web pool
298 assert:
299 that:
300 - restart_from_stop_pool is changed
301 - restart_from_stop_pool_actual.stdout == 'Started\r\n'
302
303 - name: set web pool attribute that is a collection (check mode)
304 win_iis_webapppool:
305 name: '{{test_iis_webapppool_name}}'
306 state: present
307 attributes:
308 recycling.periodicRestart.schedule: "00:10:00,10:10:00"
309 register: collection_change_check
310 check_mode: yes
311
312 - name: get result of set web pool attribute that is a collection (check mode)
313 ansible.windows.win_shell: |
314 Import-Module WebAdministration
315 (Get-ItemProperty -Path "IIS:\AppPools\{{test_iis_webapppool_name}}" -Name recycling.periodicRestart.schedule).Collection | ForEach-Object { $_.value.ToString() }
316 register: collection_change_result_check
317
318 - name: assert results of set web pool attribute that is a collection (check mode)
319 assert:
320 that:
321 - collection_change_check is changed
322 - collection_change_result_check.stdout == ""
323
324 - name: set web pool attribute that is a collection
325 win_iis_webapppool:
326 name: '{{test_iis_webapppool_name}}'
327 state: present
328 attributes:
329 recycling.periodicRestart.schedule: "00:10:00,10:10:00"
330 register: collection_change
331
332 - name: get result of set web pool attribute that is a collection
333 ansible.windows.win_shell: |
334 Import-Module WebAdministration
335 (Get-ItemProperty -Path "IIS:\AppPools\{{test_iis_webapppool_name}}" -Name recycling.periodicRestart.schedule).Collection | ForEach-Object { $_.value.ToString() }
336 register: collection_change_result
337
338 - name: assert results of set web pool attribute that is a collection
339 assert:
340 that:
341 - collection_change is changed
342 - collection_change_result.stdout_lines == [ "00:10:00", "10:10:00" ]
343
344 - name: set web pool attribute that is a collection (idempotent)
345 win_iis_webapppool:
346 name: '{{test_iis_webapppool_name}}'
347 state: present
348 attributes:
349 recycling.periodicRestart.schedule: [ "00:10:00", "10:10:00" ]
350 register: collection_change_again
351
352 - name: assert results of set web pool attribute that is a collection (idempotent)
353 assert:
354 that:
355 - collection_change_again is not changed
356
357 # The following tests are only for IIS versions 8.0 or newer
358 - block:
359 - name: delete test pool
360 win_iis_webapppool:
361 name: '{{test_iis_webapppool_name}}'
362 state: absent
363
364 - name: create test pool
365 win_iis_webapppool:
366 name: '{{test_iis_webapppool_name}}'
367 state: present
368 register: iis_attributes_blank
369
370 - name: change attributes for newer IIS version check
371 win_iis_webapppool:
372 name: '{{test_iis_webapppool_name}}'
373 state: present
374 attributes:
375 startMode: AlwaysRunning
376 processModel.identityType: SpecificUser
377 processModel.userName: '{{ansible_user}}'
378 processModel.password: '{{ ansible_password | default(ansible_test_connection_password) }}'
379 register: iis_attributes_new_check
380 check_mode: yes
381
382 - name: assert change attributes for newer IIS version check
383 assert:
384 that:
385 - iis_attributes_new_check is changed
386 - iis_attributes_new_check.info == iis_attributes_blank.info
387
388 - name: change attributes for newer IIS version
389 win_iis_webapppool:
390 name: '{{test_iis_webapppool_name}}'
391 state: present
392 attributes:
393 startMode: AlwaysRunning
394 processModel.identityType: SpecificUser
395 processModel.userName: '{{ansible_user}}'
396 processModel.password: '{{ ansible_password | default(ansible_test_connection_password) }}'
397 register: iis_attributes_new
398
399 - name: assert change attributes for newer IIS version
400 assert:
401 that:
402 - iis_attributes_new is changed
403 - iis_attributes_new.info.attributes.startMode == 'AlwaysRunning'
404 - iis_attributes_new.info.processModel.identityType == 'SpecificUser'
405 - iis_attributes_new.info.processModel.userName == ansible_user
406
407 - name: change attributes for newer IIS version again
408 win_iis_webapppool:
409 name: '{{test_iis_webapppool_name}}'
410 state: present
411 attributes:
412 startMode: AlwaysRunning
413 processModel.identityType: 3
414 processModel.userName: '{{ansible_user}}'
415 processModel.password: '{{ ansible_password | default(ansible_test_connection_password) }}'
416 register: iis_attributes_new_again
417
418 - name: assert change attributes for newer IIS version again
419 assert:
420 that:
421 - iis_attributes_new_again is not changed
422 - iis_attributes_new_again.info == iis_attributes_new.info
423
424 when: iis_version.win_file_version.file_major_part|int > 7