The ansible.windows.win_feature Module Is Installing Unexpected Features

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:
    - 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!

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 (for Windows 2012+ that is) wrapper, using these params. 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) ?

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

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

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.

1 Like

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