# Install IIS sub\_features via win\_feature module (but not ALL sub features)

**URL:** <https://forum.ansible.com/t/install-iis-sub-features-via-win-feature-module-but-not-all-sub-features/19995>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [December 12, 2015, 9:52am UTC](https://forum.ansible.com/t/install-iis-sub-features-via-win-feature-module-but-not-all-sub-features/19995 "2015-12-12T09:52:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiri.fusek](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jiri.fusek](https://forum.ansible.com/u/jiri.fusek)\
**Post date:** [December 12, 2015, 9:52am UTC](https://forum.ansible.com/t/install-iis-sub-features-via-win-feature-module-but-not-all-sub-features/19995/1 "2015-12-12T09:52:31Z")

</div>

Hello,

I have question if there is possibility via Ansible to install only particular IIS Web Server sub feature - not ALL sub features like now with property setup “include\_sub\_features: yes”. (I’m using Windows Server 2012 R2 Datacenter)

For example I want in “Common HTTP Features” of Web Server only install Default Document and Directory Browsing. NOT HTTP Error, Static Content etc.  
I want use native Ansible command, for sure there is way to execute power shell script if Ansible don’t provide any API for this.

Thank you for reply

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [December 12, 2015, 6:34pm UTC](https://forum.ansible.com/t/install-iis-sub-features-via-win-feature-module-but-not-all-sub-features/19995/2 "2015-12-12T18:34:39Z")

</div>

Absolutely. WIndows Features are a bit weird in that some have “subfeatures” and some don’t. Web-Server is an example of a windows feature with tons of subfeatures, so when you ask to install that feature, Microsoft decides the “typical” subfeatures that get included. You can verify this by using the GUI wizard. So, in order to install only the features you want, you need to figure out exactly what they are, and just install those.

The easiest way of doing that is probably to do a GUI-based install to make sure everything is exactly as you want, and then “record” the installed features by using PowerShell:  
Get-WindowsFeature|where {$_.Installed -eq $true} | where {$_.SubFeatures.count -eq 0} | select -expand name

That gives you the name of the enabled features on your box which don’t have subfeatures (e.g. the “leaf” features).

Say that this list gave you 5 features, you can easily use them with win\_features as such:

- name: Install IIS  
hosts: all  
gather\_facts: false  
tasks:
- name: Install IIS  
win\_feature:  
name: “feature1,feature2,feature3”  
state: present  
restart: no  
include\_sub\_features: no  
include\_management\_tools: yes

This will give you 100% control of exactly what gets installed. This is the recommended way to use win\_features (instead of with\_items) as all required features will be installed in one go, which is significantly faster.
