Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_iis_webapplication/tasks/main.yml

raw
1 ---
2 - name: check if we can run the tests
3 ansible.windows.win_shell: |
4 $osVersion = [Version](Get-Item -LiteralPath "$env:SystemRoot\System32\kernel32.dll").VersionInfo.ProductVersion
5 $osVersion -ge [Version]"6.2"
6 register: run_test
7 changed_when: False
8
9 - name: Run on Server 2012 and higher
10 when: run_test.stdout | trim | bool
11 block:
12 - name: ensure IIS features are installed
13 ansible.windows.win_feature:
14 name: Web-Server
15 state: present
16 include_management_tools: True
17 register: feature_install
18
19 - name: reboot after feature install
20 ansible.windows.win_reboot:
21 when: feature_install.reboot_required
22
23 # may be possible that copy corrupts the file
24 - name: Get iis configuration checksum
25 ansible.windows.win_stat:
26 path: C:\Windows\System32\inetsrv\config\applicationHost.config
27 checksum_algorithm: sha1
28 register: stat_result
29
30 - name: take a copy of the original iis configuration
31 ansible.windows.win_copy:
32 src: C:\Windows\System32\inetsrv\config\applicationHost.config
33 dest: '{{ remote_tmp_dir }}\applicationHost.config'
34 remote_src: yes
35 register: copy_result
36
37 - assert:
38 that:
39 - "stat_result.stat.checksum == copy_result.checksum"
40
41 # Tests
42 - name: run tests on hosts that support it
43 include_tasks: tests.yml
44
45 always:
46 # Cleanup
47 - name: remove test application
48 win_iis_webapplication:
49 state: absent
50 site: "{{ test_site_name }}"
51 name: "{{ test_app_name }}"
52
53 - name: remove test application pool
54 win_iis_webapppool:
55 name: "{{ test_apppool }}"
56 state: absent
57
58 - name: remove test site
59 win_iis_website:
60 name: "{{ test_site_name }}"
61 state: absent
62
63 - name: restore iis configuration
64 ansible.windows.win_copy:
65 src: '{{ remote_tmp_dir }}\applicationHost.config'
66 dest: C:\Windows\System32\inetsrv\config\applicationHost.config
67 remote_src: yes
68 register: copy_result
69
70 - assert:
71 that:
72 - "stat_result.stat.checksum == copy_result.checksum"
73
74 - name: remove IIS feature if it was installed
75 ansible.windows.win_feature:
76 name: Web-Server
77 state: absent
78 include_management_tools: True
79 when: feature_install is changed
80 register: feature_uninstall
81
82 - name: reboot after removing IIS features
83 ansible.windows.win_reboot:
84 when: feature_uninstall.reboot_required | default(False)