# win\_feature--Choose only selective sub features

**URL:** <https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048>\
**Category:** Ansible Project\
**Created:** [March 23, 2017, 6:38pm UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048 "2017-03-23T18:38:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![groupfiles14](https://avatars.discourse-cdn.com/v4/letter/g/54ee81/32.png) [@groupfiles14](https://forum.ansible.com/u/groupfiles14)\
**Post date:** [March 23, 2017, 6:38pm UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048/1 "2017-03-23T18:38:03Z")

</div>

is it possible to choose only selective sub features ? for example: IIS has so many sub features, if we install them all , there would be unnecessary footprint, so is it possible to pick and choose and install the required sub features?

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [March 23, 2017, 10:29pm UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048/2 "2017-03-23T22:29:47Z")

</div>

That’s the default behavior- just don’t specify include\_sub\_features or include\_management\_tools, and specify the exact features you want.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [March 23, 2017, 10:37pm UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048/3 "2017-03-23T22:37:51Z")

</div>

So I think you can supply this module with a comma separated list of features to add. If I recall, you can generate a list of all the modules and submodules by running the following PowerShell

Get-Feature | Out-GridView

I think you should be able to pick out the exact features you need from the list that is displayed.

By the way Out-GridView needs a UI to display so you would need to remote desktop to the windows box to run it or send the output to a different Out- ... Cmdlet. From memory there are Out cmdlets to convert to CSV, XML or Json

Hope this helps,

let us know how you get on.

Jon

---

<div class="post-metadata">

**Author:** ![groupfiles14](https://avatars.discourse-cdn.com/v4/letter/g/54ee81/32.png) [@groupfiles14](https://forum.ansible.com/u/groupfiles14)\
**Post date:** [March 24, 2017, 11:14am UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048/4 "2017-03-24T11:14:46Z")

</div>

Things i learnt in this, choose a sub feature in windows and that will make sure that the parent feature of that sub feature will be ticked, when you see in server manager… if you choose the parent feature alone it will not install the sub feature, instead it will just tick the parent feature :-o . So we have to choose the exact sub feature we want in a role to make sure that we are installing only that. i am using 2.3 rc1

---

<div class="post-metadata">

**Author:** ![groupfiles14](https://avatars.discourse-cdn.com/v4/letter/g/54ee81/32.png) [@groupfiles14](https://forum.ansible.com/u/groupfiles14)\
**Post date:** [March 24, 2017, 11:17am UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048/5 "2017-03-24T11:17:01Z")

</div>

another thing, if you choose the sub feature alone, it will install the required dependent feature of it by default, you need not choose that again, if you choose that , it will show as not changed in the output.

i am using with\_items and added every feature i want…is there any other better way to achieve this?

---

<div class="post-metadata">

**Author:** ![meaton](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@meaton](https://forum.ansible.com/u/meaton)\
**Post date:** [March 24, 2017, 12:55pm UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048/6 "2017-03-24T12:55:16Z")

</div>

That’s exactly how I do it… see below:

```auto
---

```

```auto
- name: Install Roles and Features
  win_feature:
    name: "{{ item }}"
    state: present
    restart: true
    include_management_tools: true
  with_items: " {{ win_roles }} "

```

```auto

```

```auto

```

```auto

```

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [March 24, 2017, 3:00pm UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048/7 "2017-03-24T15:00:26Z")

</div>

You can use a comma separated list of feature names which might be faster than using with\_items in this case, although there’s probably less of a time penalty with the new exec wrapper in 2.3.

Jon

---

<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:** [March 26, 2017, 9:23pm UTC](https://forum.ansible.com/t/win-feature-choose-only-selective-sub-features/24048/8 "2017-03-26T21:23:08Z")

</div>

Remember that on Windows a “feature” containing sub-features is only just a grouping, there’s “nothing” inside the “WebServer” feature itself for instance.

We only install “leaf features” using win\_feature to make sure we’re in total control of what gets applied. On a Windows box you can list these using:  
`get-windowsfeature | where {$_.SubFeatures.count -eq 0}`
