community.windows
community.windows copied to clipboard
Add win_iis_webhandler
SUMMARY
The iis
modules are missing any way to manage handlers in IIS.
It looks like @arestarh had a PR ready to go to support this: https://github.com/ansible/ansible/pull/45998
But it was rejected because:
After some discussion at the Windows Working Group module review, we're a little nervous to take on more IIS modules into the core distribution right now, especially given the state of the other IIS modules we already have. This would be a good candidate for the new collections feature that's coming in Ansible 2.8, which would allow these modules to be hosted on galaxy.ansible.com and easily installed/upated by users on their Ansible controller.
https://github.com/ansible/ansible/pull/45998#issuecomment-459949742
ISSUE TYPE
- Feature Idea
COMPONENT NAME
community.windows.win_iis_webhandler
ADDITIONAL INFORMATION
- name: Create http handler to process php files
win_iis_webhandler:
name: php-fastcgi
script_processor: C:\ProgramData\php\php-cgi.exe
modules: FastCgiModule
path: '*.php'
verb: '*'
state: present
- name: Adds a handler named "testHandler" to the Default Web Site
win_iis_webhandler:
name: testHandler
modules: IsapiModule
path: '*.test'
verb: 'GET,POST'
site_name: Default Web Site
state: present
⬆️ copied from: https://github.com/arestarh/ansible/blob/65c3857cfa8794240c529b54297e338c5dc6a376/lib/ansible/modules/windows/win_iis_webhandler.py#L123-L141
It appears there might be a workaround for this using ansible.windows.win_dsc
.
The last example shows how dsccommunity/xWebAdministration
can be used:
- name: Create IIS Website with Binding and Authentication options
ansible.windows.win_dsc:
resource_name: xWebsite
...
And xWebAdministration
appears to support webapplicationhandler
, which might be what we need.
I couldn't get that workaround ⬆️ working due to https://github.com/dsccommunity/xWebAdministration/issues/573
But I was able to workaround that with this:
- name: Create FastCGI handler
ansible.windows.win_shell: |
$name = "my-FastCGI-handler"
$site = "mysite"
$scriptprocessor = "C:\Python34\python.exe|D:\inetpub\mysite\wfastcgi.py"
$handler = Get-WebHandler -name $name -PSPath "IIS:\Sites\$site\"
if(!$handler) {
New-WebHandler -Name $name -Path "*" -Verb "*" -Modules "FastCgiModules" -ScriptProcessor $scriptprocessor -ResourceType Either -PSPath "IIS:\Sites\$site\"
}
I found New-WebHandler
from a suggested workaround in the description of https://github.com/dsccommunity/xWebAdministration/issues/573, but I'm not sure why it isn't used in webhandler.ps1
in@arestarh 's PR?
I'm pretty new to all this, but I'm happy to have a go if someone could point me to what the next steps are 😁