ansible-collections / community.windows

Windows community collection for Ansible
https://galaxy.ansible.com/community/windows
GNU General Public License v3.0
206 stars 161 forks source link

win_iis_webapplication - Cannot Set preloadEnabled #192

Open 67726e opened 3 years ago

67726e commented 3 years ago
SUMMARY

One can set the preloadEnabled on both a Site and Application-level in IIS, however the current Ansible module for IIS only appears to have this option on the Site-level.

See Also: https://github.com/ansible/ansible/issues/66831

ISSUE TYPE
COMPONENT NAME

community.windows.win_iis_webapplication

ADDITIONAL INFORMATION

At work, we currently have a handful of applications under the same website so that they are on the same domain, e.g. site.com/app1, site.com/app2, etc. We have these applications configured under their own application pools such that one API / site error will not take down the pool for another.

In this specific case, we have a need for an application pool running with startMode: alwaysRunning and the application running with preloadEnabled: true.

See: https://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html

---
- hosts: all
  tasks:
          - name: Create Application Pool
            community.windows.win_iis_webapppool:
                    name: "SomeApplication"
                    state: present
                    attributes:
                            autoStart: yes
                            startMode: alwaysRunning

          - name: Create Web Application
            community.windows.win_iis_webapplication:
                    name: "SomeApplication"
                    state: present
                    application_pool: "SomeApplication"
                    site: "Default Web Site"
                    # SUGGESTED
                    attributes:
                            preloadEnabled: yes
67726e commented 3 years ago

As a workaround for the intrepid developer, I am able to use the following PowerShell:

Set-ItemProperty "IIS:\Sites\Default Web Site\SomeApplication" -name preloadEnabled -value True