ansible.windows.win_capability module – Manage Windows capabilities

Note

This module is part of the ansible.windows collection (version 3.5.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. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: ansible.windows.win_capability.

New in ansible.windows 3.6.0

Synopsis

  • Add or remove Windows capabilities from a Windows target.

  • A Windows capability is an optional feature that can be added to Windows.

Requirements

The below requirements are needed on the host that executes this module.

  • Windows Server 2019/Windows 10 build 1809 or newer for PowerShell 5.1

  • Windows Server 2022/Windows 10 build 1903 or newer for PowerShell 7.x

Parameters

Parameter

Comments

disable_windows_update

boolean

If true, prevents DISM from contacting Windows Update for the source files.

Choices:

  • false ← (default)

  • true

log_level

integer

Sets the maximum output level for DISM logging.

0 logs errors only

1 logs errors and warnings

2 logs errors, warnings, and information

3 logs all of the previous plus debug output, only valid on Windows 11 or Server 2025 or newer.

This log is managed by DISM itself, the values allowed may change with different versions of Windows.

log_path

path

Specifies the full path and file name to log to.

If not specified the logging uses the default DISM log file location which is %WINDIR%\Logs\Dism\dism.log.

name

list / elements=string / required

A list of capability names to add or remove.

Supports wildcard patterns like ? for single character matching and * for multiple character matching.

source

list / elements=string

Use the specified locations as capability sources.

state

string

Whether the capability should be present or absent.

If present, the capability will be added if it is not already present.

If absent, the capability will be removed if it is present.

Choices:

  • "absent"

  • "present" ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target, if not supported the action will be skipped.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode

platform

Platform: windows

Target OS/families that can be operated against

Notes

Note

  • Adding a capability requires the target user to have the SeBatchLogonRight user right. Use ansible.windows.win_user_right to manage this user right.

  • This module does not support Server 2016.

See Also

See also

ansible.windows.win_capability_info

Get information about Windows capabilities.

Examples

- name: Install OpenSSH Client capability using short name
  ansible.windows.win_capability:
    name: OpenSSH.Client
    state: present

- name: Install OpenSSH Client capability using full name
  ansible.windows.win_capability:
    name: OpenSSH.Client~~~~0.0.1.0
    state: present

- name: Install both OpenSSH Client and OpenSSH Server capabilities using list
  ansible.windows.win_capability:
    name:
      - OpenSSH.Client
      - OpenSSH.Server
    state: present

- name: Install both OpenSSH Client and OpenSSH Server capabilities using wildcard pattern
  ansible.windows.win_capability:
    name: OpenSSH.*
    state: present

- name: Remove OpenSSH Client capability
  ansible.windows.win_capability:
    name: OpenSSH.Client
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

capabilities

list / elements=string

A list of capabilities that were added or removed.

Returned: always

reboot_required

boolean

Whether a reboot is required to complete the operation.

Returned: always

Authors

  • Jordan Borean (@jborean93)