Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I configure IIS subfeatures in Ansible

Tags:

iis

ansible

New to Ansible I'm experimenting with setting up a website under IIS. I can create and configure an application pool, but I'm struggling with the website. The basic site works, HTTPS/SSL is still troublesome, but I read there are some bugs in the win_iis_website/win_iis_webbinding scripts that are being worked on. The part I'm stuck with are IIS' features per site.

In IIS (in the GUI) there are sub-features that can be configured for a site: example IIS site screen

I was unable to find how to configure these using Ansible (more specifically Ansible's win_iis_website module). I'm looking to configure ASP, Handler mappings, URL rewrites and Default documents.

Is there any way to do so?

My current yml for creating the site looks like this:

  - name:  create new website {{ websitename}}
    win_iis_website:
      name: "{{ websitename}}"
      state: started
      port: 443
      ip: *
      ssl: true
      hostname: "{{ websitename }}"
      application_pool: "{{ websitename }}"
      physical_path: c:\inetpub\wwwroot\{{ websitename }}
      parameters: logfile.directory:c:\inetpub\logs\
    register: website
like image 326
Erik Oosterwaal Avatar asked Oct 22 '25 22:10

Erik Oosterwaal


2 Answers

I am currently making Playbooks for IIS and indeed to perform the configuration there is no particular module that allows you to modify the functions of the sections, I looked in some places and the information was very scarce, there are modules for applicationPool, but for this you have to use win_shell as follows

- name: Name of playbook
  win_shell: |
    <PowerShell command>

You can base on the CIS BENCHMARK guide of IIS.

like image 199
Galo Candela Avatar answered Oct 25 '25 05:10

Galo Candela


Check the win_feature module:

- name: Install IIS Web-Server with sub features and management tools
  win_feature:
    name: Web-Server
    state: present
    restart: True
    include_sub_features: True
    include_management_tools: True

if you want to do in a more controlled manner, check the installed features with the command:

Get-WindowsFeature

And add like:

    - name: Install IIS
      win_feature:
        name: "Web-Filtering,Web-Dir-Browsing,Web-Default-Doc"
        state: present
        restart: no
        include_sub_features: no
        include_management_tools: yes
like image 45
imjoseangel Avatar answered Oct 25 '25 06:10

imjoseangel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!