ansible.windows.win_feature module – Installs and uninstalls Windows Features on Windows Server
Note
This module is part of the ansible.windows collection (version 3.2.0).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install ansible.windows.
To use it in a playbook, specify: ansible.windows.win_feature.
Synopsis
- Installs or uninstalls Windows Roles or Features on Windows Server. 
- This module uses the Add/Remove-WindowsFeature Cmdlets on Windows 2008 R2 and Install/Uninstall-WindowsFeature Cmdlets on Windows 2012, which are not available on client os machines. 
Parameters
| Parameter | Comments | 
|---|---|
| Adds the corresponding management tools to the specified feature. Not supported in Windows 2008 R2 and will be ignored. Choices: 
 | |
| Adds all subfeatures of the specified feature. Choices: 
 | |
| Names of roles or features to install as a single feature or a comma-separated list of features. To list all available features use the PowerShell command  | |
| Specify a source to install the feature from. Not supported in Windows 2008 R2 and will be ignored. Can either be  | |
| State of the features or roles on the system. Choices: 
 | 
See Also
See also
- chocolatey.chocolatey.win_chocolatey
- The official documentation on the chocolatey.chocolatey.win_chocolatey module. 
- ansible.windows.win_package
- Installs/uninstalls an installable package. 
Examples
- name: Install IIS (Web-Server only)
  ansible.windows.win_feature:
    name: Web-Server
    state: present
- name: Install IIS (Web-Server and Web-Common-Http)
  ansible.windows.win_feature:
    name:
      - Web-Server
      - Web-Common-Http
    state: present
- name: Install NET-Framework-Core from file
  ansible.windows.win_feature:
    name: NET-Framework-Core
    source: C:\Temp\iso\sources\sxs
    state: present
- name: Install IIS Web-Server with sub features and management tools
  ansible.windows.win_feature:
    name: Web-Server
    state: present
    include_sub_features: true
    include_management_tools: true
  register: win_feature
- name: Reboot if installing Web-Server feature requires it
  ansible.windows.win_reboot:
  when: win_feature.reboot_required
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| The stringified exit code from the feature installation/removal command. Returned: always Sample:  | |
| List of features that were installed or removed. Returned: success | |
| Feature display name. Returned: always Sample:  | |
| A list of KB article IDs that apply to the update. Returned: always Sample:  | |
| Any messages returned from the feature subsystem that occurred during installation or removal of this feature. Returned: always Sample:  | |
| True when the target server requires a reboot as a result of installing or removing this feature. Returned: always Sample:  | |
| The reason a feature installation or removal was skipped. Returned: always Sample:  | |
| If the feature installation or removal was successful. Returned: always Sample:  | |
| True when the target server indicates a reboot is required (no further updates can be installed until after a reboot). This my be true even if not change had occurred as the value is derived from the server state. Returned: success Sample:  | 
