Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_iis_webbinding/tasks/setup.yml

raw
1 - name: reboot before feature install to ensure server is in clean state
2 ansible.windows.win_reboot:
3
4 - name: ensure IIS features are installed
5 ansible.windows.win_feature:
6 name: Web-Server
7 state: present
8 include_management_tools: True
9 register: feature_install
10
11 - name: reboot after feature install
12 ansible.windows.win_reboot:
13 when: feature_install.reboot_required
14
15 - name: get all websites from server
16 raw: powershell.exe "(get-website).name"
17 register: existing_sites
18
19 - name: ensure all sites are removed for clean testing
20 win_iis_website:
21 name: "{{ item }}"
22 state: absent
23 with_items:
24 - "{{ existing_sites.stdout_lines }}"
25
26 - name: add testing site {{ test_iis_site_name }}
27 win_iis_website:
28 name: "{{ test_iis_site_name }}"
29 physical_path: c:\inetpub\wwwroot
30
31 - name: ensure all bindings are removed prior to starting testing
32 win_iis_webbinding:
33 name: "{{ test_iis_site_name }}"
34 state: absent
35 protocol: "{{ item.protocol }}"
36 port: "{{ item.port }}"
37 with_items:
38 - {protocol: http, port: 80}
39 - {protocol: https, port: 443}
40
41 - name: copy certreq file
42 ansible.windows.win_copy:
43 content: |-
44 [NewRequest]
45 Subject = "CN={{ item.name }}"
46 KeyLength = 2048
47 KeyAlgorithm = RSA
48 MachineKeySet = true
49 RequestType = Cert
50 dest: "{{ item.dest }}"
51 with_items:
52 - {name: test.com, dest: 'c:\windows\temp\certreq1.txt'}
53 - {name: test1.com, dest: 'c:\windows\temp\certreq2.txt'}
54 - {name: '*.test.com', dest: 'c:\windows\temp\certreqwc.txt'}
55
56 - name: make sure response files are absent
57 ansible.windows.win_file:
58 path: "{{ item }}"
59 state: absent
60 with_items:
61 - 'c:\windows\temp\certreqresp1.txt'
62 - 'c:\windows\temp\certreqresp2.txt'
63 - 'c:\windows\temp\certreqrespwc.txt'
64
65 - name: create self signed cert from certreq
66 ansible.windows.win_command: certreq -new -machine {{ item.req }} {{ item.resp }}
67 with_items:
68 - {req: 'c:\windows\temp\certreq1.txt', resp: 'c:\windows\temp\certreqresp1.txt'}
69 - {req: 'c:\windows\temp\certreq2.txt', resp: 'c:\windows\temp\certreqresp2.txt'}
70 - {req: 'c:\windows\temp\certreqwc.txt', resp: 'c:\windows\temp\certreqrespwc.txt'}
71
72 - name: register certificate thumbprint1
73 raw: '(gci Cert:\LocalMachine\my | ? {$_.subject -eq "CN=test.com"})[0].Thumbprint'
74 register: thumbprint1
75
76 - name: register certificate thumbprint2
77 raw: '(gci Cert:\LocalMachine\my | ? {$_.subject -eq "CN=test1.com"})[0].Thumbprint'
78 register: thumbprint2
79
80 - name: register certificate thumbprint_wc
81 raw: '(gci Cert:\LocalMachine\my | ? {$_.subject -eq "CN=*.test.com"})[0].Thumbprint'
82 register: thumbprint_wc
83
84 - debug:
85 var: thumbprint1.stdout
86 verbosity: 1
87 - debug:
88 var: thumbprint2.stdout
89 verbosity: 1
90 - debug:
91 var: thumbprint_wc.stdout
92 verbosity: 1