win_feature--Choose only selective sub features

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?

That’s the default behavior- just don’t specify include_sub_features or include_management_tools, and specify the exact features you want.

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

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

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?

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

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



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

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}