Created
February 22, 2018 17:54
-
-
Save gravcat/a20417e772661b63d6fc2cc0e1c6b3d0 to your computer and use it in GitHub Desktop.
via Ansible, check whether or not a Windows feature is in an "Enabled" state. Conditional to enable feature if it is determined to not be in an Enabled state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
tasks: | |
- name: Check for WSL feature enablement | |
win_shell: "(Get-WindowsOptionalFeature -Online -FeatureName 'Microsoft-Windows-Subsystem-Linux').State" | |
register: wsl_check | |
- name: Install WSL Feature | |
win_shell: "{{ item }}" | |
with_items: | |
- "Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName Microsoft-Windows-Subsystem-Linux" | |
- "Start-Sleep -s 10" | |
when: wsl_check.stdout_lines != "Enabled" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment