ansible.builtin.win_optional_feature (v2.9.27) — module

Manage optional Windows features

| "added in version" 2.8 of ansible.builtin"

Authors: Carson Anderson (@rcanderson23)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Install or uninstall optional Windows features on non-Server Windows.

This module uses the C(Enable-WindowsOptionalFeature) and C(Disable-WindowsOptionalFeature) cmdlets.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install .Net 3.5
  win_optional_feature:
    name: NetFx3
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install .Net 3.5 from source
  win_optional_feature:
    name: NetFx3
    source: \\share01\win10\sources\sxs
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install Microsoft Subsystem for Linux
  win_optional_feature:
    name: Microsoft-Windows-Subsystem-Linux
    state: present
  register: wsl_status
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Reboot if installing Linux Subsytem as feature requires it
  win_reboot:
  when: wsl_status.reboot_required
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install multiple features in one task
  win_optional_feature:
    name:
    - NetFx3
    - Microsoft-Windows-Subsystem-Linux
    state: present

Inputs

    
name:
    description:
    - The name(s) of the feature to install.
    - This relates to C(FeatureName) in the Powershell cmdlet.
    - To list all available features use the PowerShell command C(Get-WindowsOptionalFeature).
    required: true
    type: list

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Whether to ensure the feature is absent or present on the system.
    type: str

source:
    description:
    - Specify a source to install the feature from.
    - Can either be C({driveletter}:\sources\sxs) or C(\\{IP}\share\sources\sxs).
    type: str

include_parent:
    default: false
    description:
    - Whether to enable the parent feature and the parent's dependencies.
    type: bool

Outputs

reboot_required:
  description: True when the target server requires a reboot to complete updates
  returned: success
  sample: true
  type: bool

See also