ansible-collections / community.windows

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

win_iis_website: No option to change Ananymous and Windows authentication #417

Open Udayendu opened 2 years ago

Udayendu commented 2 years ago
SUMMARY

Currently there is no option to change the anonymous and windows authentication using win_iis_website module

ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
$ pip3 show ansible
Name: ansible
Version: 5.8.0
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: info@ansible.com
License: GPLv3+
Location: /usr/local/lib/python3.8/dist-packages
Requires: ansible-core
Required-by:
COLLECTION VERSION
$ ansible-galaxy collection list community.windows

# /usr/local/lib/python3.8/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.windows 1.10.0
CONFIGURATION
OS / ENVIRONMENT
EXPECTED RESULTS
ACTUAL RESULTS
- name: Unlock IIS anonymous Authentication property
  win_shell: Set-WebConfiguration -Filter "/system.webserver/security/authentication/anonymousAuthentication" -PSPath "machine/webroot/apphost" -Metadata "overrideMode" -Value "Allow"

- name: Disable IIS MyWebApp Site Anonymous Authentication
  win_shell: Set-WebConfigurationProperty -Filter "/system.webServer/security/authentication/anonymousAuthentication" -Name Enabled -Value False -PSPath "IIS:\Sites\MyWebApp"
  register: result

- name: Unlock IIS Windows Authentication property
  win_shell: Set-WebConfiguration -Filter "/system.webserver/security/authentication/windowsAuthentication" -PSPath "machine/webroot/apphost" -Metadata "overrideMode" -Value "Allow"

- name: Enable IIS MyWebApp Site Windows Authentication
  win_shell: Set-WebConfigurationProperty -Filter "/system.webServer/security/authentication/windowsAuthentication" -Name Enabled -Value True -PSPath "IIS:\Sites\MyWebApp"
  register: result
jeremyhallock commented 2 years ago

@Udayendu I would like to see that functionality as well, but in the meantime, you can use the win_dsc module to accomplish this. An example for a web application is here:

- name: Install xWebAdministration module 
  win_psmodule: 
    name: xWebAdministration 
    state: present 

- name: "Setting Windows Auth as 'Enabled' and Anonymous Auth as 'Disabled'..." 
  win_dsc: 
    resource_name: xWebApplication
    Name: MyWebSite
    Ensure: Present
    PhysicalPath: C:\inetpub\wwwroot\
    Website: 'Default Web Site'
    WebAppPool: {{ app_pool }}
    AuthenticationInfo:
      Windows: yes
      Anonymous: no 
Udayendu commented 2 years ago

Thanks @jeremyhallock :)