mirror of https://github.com/ansible/ansible.git
win_iis_webapplication: add authentication parameters (#56033)
* add connect_as, username, password parameters add tests * fixed reference to undefined variable. added version added to new options. * add changelog fragment * fix line endings * use ansible facts to determine os version remove unused iis version check test checksum of iis configuration after backup * correct assertion * added more cleanup tasks. * version added is now 2.10 * skip server 2008 r2 for now * run tests on server 2012 and higherpull/64493/head
parent
40071e5db3
commit
8ff6e4c68e
@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- "win_iis_webapplication - add new options ``connect_as``, ``username``, ``password``."
|
@ -0,0 +1 @@
|
|||||||
|
shippable/windows/group3
|
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
test_app_name: TestApp
|
||||||
|
|
||||||
|
test_site_name: 'Test Site'
|
||||||
|
|
||||||
|
test_user: testuser
|
||||||
|
test_password: testpass
|
||||||
|
|
||||||
|
test_physical_path: "{{ remote_tmp_dir }}"
|
||||||
|
test_apppool: 'testapppool'
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- setup_remote_tmp_dir
|
@ -0,0 +1,70 @@
|
|||||||
|
---
|
||||||
|
# Cannot use win_feature to install IIS on Server 2008.
|
||||||
|
# Run a brief check and skip hosts that don't support
|
||||||
|
# that operation
|
||||||
|
|
||||||
|
# Run on Server 2012 and higher
|
||||||
|
- block:
|
||||||
|
- name: ensure IIS features are installed
|
||||||
|
win_feature:
|
||||||
|
name: Web-Server
|
||||||
|
state: present
|
||||||
|
include_management_tools: True
|
||||||
|
register: feature_install
|
||||||
|
|
||||||
|
- name: reboot after feature install
|
||||||
|
win_reboot:
|
||||||
|
when: feature_install.reboot_required
|
||||||
|
|
||||||
|
# may be possible that copy corrupts the file
|
||||||
|
- name: Get iis configuration checksum
|
||||||
|
win_stat:
|
||||||
|
path: '{{ ansible_env.SystemRoot }}\System32\inetsrv\config\applicationHost.config'
|
||||||
|
checksum_algorithm: sha1
|
||||||
|
register: stat_result
|
||||||
|
|
||||||
|
- name: take a copy of the original iis configuration
|
||||||
|
win_copy:
|
||||||
|
src: '{{ ansible_env.SystemRoot }}\System32\inetsrv\config\applicationHost.config'
|
||||||
|
dest: '{{ ansible_env.TEMP }}\applicationHost.config'
|
||||||
|
remote_src: yes
|
||||||
|
register: copy_result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "stat_result.stat.checksum == copy_result.checksum"
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
- name: run tests on hosts that support it
|
||||||
|
include_tasks: tests.yml
|
||||||
|
|
||||||
|
always:
|
||||||
|
# Cleanup
|
||||||
|
- name: remove test application
|
||||||
|
win_iis_webapplication:
|
||||||
|
state: absent
|
||||||
|
site: "{{ test_site_name }}"
|
||||||
|
name: "{{ test_app_name }}"
|
||||||
|
|
||||||
|
- name: remove test application pool
|
||||||
|
win_iis_webapppool:
|
||||||
|
name: "{{ test_apppool }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: remove test site
|
||||||
|
win_iis_website:
|
||||||
|
name: "{{ test_site_name }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: restore iis configuration
|
||||||
|
win_copy:
|
||||||
|
src: '{{ ansible_env.TEMP }}\applicationHost.config'
|
||||||
|
dest: '{{ ansible_env.SystemRoot }}\System32\inetsrv\config\applicationHost.config'
|
||||||
|
remote_src: yes
|
||||||
|
register: copy_result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "stat_result.stat.checksum == copy_result.checksum"
|
||||||
|
|
||||||
|
when: ansible_distribution_version is version('6.2','ge')
|
@ -0,0 +1,91 @@
|
|||||||
|
---
|
||||||
|
- name: test site exists, but stopped in case of duplicate web binding
|
||||||
|
win_iis_website:
|
||||||
|
name: "{{ test_site_name }}"
|
||||||
|
state: stopped
|
||||||
|
physical_path: 'C:\inetpub\wwwroot'
|
||||||
|
|
||||||
|
- name: test app is absent (baseline)
|
||||||
|
win_iis_webapplication:
|
||||||
|
state: absent
|
||||||
|
site: "{{ test_site_name }}"
|
||||||
|
name: "{{ test_app_name }}"
|
||||||
|
|
||||||
|
- name: create test app
|
||||||
|
win_iis_webapplication:
|
||||||
|
state: present
|
||||||
|
site: "{{ test_site_name }}"
|
||||||
|
name: "{{ test_app_name }}"
|
||||||
|
physical_path: "{{ test_physical_path }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- 'result.changed == true'
|
||||||
|
- 'result.physical_path == test_physical_path'
|
||||||
|
|
||||||
|
- name: create test app (idempotent)
|
||||||
|
win_iis_webapplication:
|
||||||
|
state: present
|
||||||
|
site: "{{ test_site_name }}"
|
||||||
|
name: "{{ test_app_name }}"
|
||||||
|
physical_path: "{{ test_physical_path }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- 'result.changed == false'
|
||||||
|
- 'result.physical_path == test_physical_path'
|
||||||
|
|
||||||
|
- name: set test app credentials
|
||||||
|
win_iis_webapplication:
|
||||||
|
state: present
|
||||||
|
site: "{{ test_site_name }}"
|
||||||
|
name: "{{ test_app_name }}"
|
||||||
|
connect_as: specific_user
|
||||||
|
username: "{{ test_user }}"
|
||||||
|
password: "{{ test_password }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- 'result.changed == true'
|
||||||
|
- 'result.physical_path == test_physical_path'
|
||||||
|
- "result.connect_as == 'specific_user'"
|
||||||
|
|
||||||
|
- name: set test app credentials (idempotent)
|
||||||
|
win_iis_webapplication:
|
||||||
|
state: present
|
||||||
|
site: "{{ test_site_name }}"
|
||||||
|
name: "{{ test_app_name }}"
|
||||||
|
connect_as: specific_user
|
||||||
|
username: "{{ test_user }}"
|
||||||
|
password: "{{ test_password }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- 'result.changed == false'
|
||||||
|
- 'result.physical_path == test_physical_path'
|
||||||
|
- "result.connect_as == 'specific_user'"
|
||||||
|
|
||||||
|
- name: create new test application pool
|
||||||
|
win_iis_webapppool:
|
||||||
|
name: "{{ test_apppool }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: change app pool and use pass through authentication
|
||||||
|
win_iis_webapplication:
|
||||||
|
state: present
|
||||||
|
site: "{{ test_site_name }}"
|
||||||
|
name: "{{ test_app_name }}"
|
||||||
|
connect_as: pass_through
|
||||||
|
application_pool: "{{ test_apppool }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- 'result.changed == true'
|
||||||
|
- 'result.physical_path == test_physical_path'
|
||||||
|
- "result.connect_as == 'pass_through'"
|
||||||
|
- "result.application_pool == test_apppool"
|
Loading…
Reference in New Issue