# The ansible.windows.win\_feature Module Is Installing Unexpected Features

**URL:** <https://forum.ansible.com/t/the-ansible-windows-win-feature-module-is-installing-unexpected-features/3388>\
**Category:** Get Help\
**Tags:** windows, collections\
**Created:** [January 18, 2024, 7:17pm UTC](https://forum.ansible.com/t/the-ansible-windows-win-feature-module-is-installing-unexpected-features/3388 "2024-01-18T19:17:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tompurl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tompurl/32/2031_2.png) [@tompurl](https://forum.ansible.com/u/tompurl)\
**Post date:** [January 18, 2024, 7:17pm UTC](https://forum.ansible.com/t/the-ansible-windows-win-feature-module-is-installing-unexpected-features/3388/1 "2024-01-18T19:17:54Z")

</div>

I setup a **Windows 2019** server 100% manually a little while ago (ServerA) and I need to also setup a copy of it (ServerB) that runs on the same OS. Since I am now using Ansible for provisioning I thought it would be nice create some playbooks that I can run against both servers. My assumption is that **only the new server should change** when I run these playbooks.

To start, I:

1. Made a list of all of the **Modules and Features** that were installed on ServerA and then…
2. Created a playbook that uses the `ansible.windows.win_feature` module to install all of the desired features **explicitly**. Here’s an example of one of the tasks:

```yaml
    - name: Install Powershell
      ansible.windows.win_feature:
        name:
          - PowerShellRoot
          - PowerShell
          - PowerShell-V2
          - PowerShell-ISE
        state: present
        install_sub_features: false

```

I then ran this playbook **against ServerA** and expected that **nothing should change**. But things did change, and some features that weren’t specified were installed.

Does anyone know why this would happen? For the record I also set the `install_sub_features` and `include_management_tools` properties of the module to false.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [January 19, 2024, 8:11pm UTC](https://forum.ansible.com/t/the-ansible-windows-win-feature-module-is-installing-unexpected-features/3388/2 "2024-01-19T20:11:57Z")

</div>

Hey,

> some features that weren’t specified were installed

What were they ? And what makes you say that (playbook output, `Get-WindowsFeature` you ran afterwards, logs, etc…) ?

`ansible.windows.win_feature` is essentially an [`Install-WindowsFeature`](https://learn.microsoft.com/en-us/powershell/module/servermanager/install-windowsfeature?view=windowsserver2022-ps) (for Windows 2012+ that is) wrapper, using [these params](https://github.com/ansible-collections/ansible.windows/blob/main/plugins/modules/win_feature.ps1#L39). Also management tools and subfeatures install default to `false`.

I’m not very familiar with `Install-WindowsFeature` cmdlet as I don’t work much with Windows Server these days, but it seems to me it should only install specified features. If you could somehow rollback your machine state and try again with plain `Install-WindowsFeature` cmdlet, I’m curious how it would perform.

Also, is your example task representative of the one you ran against your server ? Same parameters (except `name` value perhaps) ?

---

<div class="post-metadata">

**Author:** ![tompurl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tompurl/32/2031_2.png) [@tompurl](https://forum.ansible.com/u/tompurl)\
**Post date:** [January 23, 2024, 9:35pm UTC](https://forum.ansible.com/t/the-ansible-windows-win-feature-module-is-installing-unexpected-features/3388/3 "2024-01-23T21:35:13Z")

</div>

> [@ptn](#):
>
> What were they ? And what makes you say that (playbook output, `Get-WindowsFeature` you ran afterwards, logs, etc…) ?

I’d rather not list them in a public forum for security reasons.

> [@ptn](#):
>
> If you could somehow rollback your machine state and try again with plain `Install-WindowsFeature` cmdlet, I’m curious how it would perform.

That’s a really good idea. I’m going to try that in a few weeks when I can.

> [@ptn](#):
>
> Also, is your example task representative of the one you ran against your server ? Same parameters (except `name` value perhaps) ?

Yes it is.

I appreciate your help! I imagine that you’re correct, that i need to address what is happening at the `Install-WindowsFeature`, not the ansible level. However, I can’t test this for a few weeks so I will close this post. If I still have an issue I’ll open a bug.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 22, 2024, 9:36pm UTC](https://forum.ansible.com/t/the-ansible-windows-win-feature-module-is-installing-unexpected-features/3388/4 "2024-02-22T21:36:05Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
