Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add win_iis_webhandler #145

Open
davetapley opened this issue Sep 29, 2020 · 2 comments
Open

Add win_iis_webhandler #145

davetapley opened this issue Sep 29, 2020 · 2 comments

Comments

@davetapley
Copy link

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:
ansible/ansible#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.

ansible/ansible#45998 (comment)

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

@davetapley
Copy link
Author

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.

@davetapley
Copy link
Author

I couldn't get that workaround ⬆️ working due to dsccommunity/WebAdministrationDsc#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 dsccommunity/WebAdministrationDsc#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 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant