Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: Support for managing Windows Capabilities #660

Open
myllynen opened this issue Sep 23, 2024 · 2 comments
Open

RFE: Support for managing Windows Capabilities #660

myllynen opened this issue Sep 23, 2024 · 2 comments

Comments

@myllynen
Copy link

SUMMARY

Recent Windows Server versions allow for adding, querying, and removing Windows capabilities which are separate from features, optional features, and packages. For example, to check the installation status of OpenSSH SSH Server (sshd) on Windows Server 2022 and install it if not installed already one could do:

if (Get-WindowsCapability -Name OpenSSH.Server -Online | ? State -ne 'Installed') {
  Add-WindowsCapability -Name OpenSSH.Server -Online
}

It would be helpful if there would be an Ansible Windows module available to do this without the need for writing PowerShell.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

win_capability

ADDITIONAL INFORMATION

The Add-WindowsCapability, Get-WindowsCapability, and Remove-WindowsCapability PowerShell cmdlets seem to use Dism.exe. While the aforementioned example works as expected on Windows Server 2022 it doesn't seem to do anything on Windows 10. Also, when trying to install other capabilities such as languages the results seem inconsistent, I haven't been able to handle them reliably even if similar language enablement using Settings works as expected. Meaning that if creating this kind of module it should verify the outcome to the extent possible.

- name: Install OpenSSH SSH server (sshd)
  ansible.windows.win_capability:
    name: OpenSSH.Server
    state: present
  register: install_status

- name: Remove Azure Arc client setup
  ansible.windows.win_capability:
    name: AzureArcSetup
    state: absent
  register: remove_status

- name: Check available Windows Capabilities
  ansible.windows.win_capability:
    state: available
  register: available_capabilities

- name: Check already installed Windows Capabilities
  ansible.windows.win_capability:
    state: installed
  register: installed_capabilities
@myllynen
Copy link
Author

For reference, here are the most relevant documents available online, the DISM commands and PowerShell cmdlets use the term capability but the documents talk about Features on Demand (FODs):

https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/features-on-demand-v2--capabilities?view=windows-11
https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/features-on-demand-language-fod?view=windows-11
https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/features-on-demand-non-language-fod?view=windows-11

I think the issue I mentioned earlier about inconsistent results was probably due to a typo somewhere. For example, trying to install 'OpenSSH-Server~~~~0.0.1.0' doesn't really do anything but does not give a clear error either as some might except due to using wrong name, it should be 'OpenSSH.Server~~~~0.0.1.0' not 'OpenSSH-Server~~~~0.0.1.0'. Thanks.

@jborean93
Copy link
Collaborator

This is certainly something we should probably look into. Things like invalid names should of course be detected and produce an error with a more obvious reason why it failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants