Do you know if DSC can be used to install WindowsCapablity features? Is there a resource for this? It seems to me if I can get this to work with DSC, I can get it to deploy. This playbook runs 15 other configurations fine, including add Window Features.
Ooops … I missed that … sorry. But why does it have to be used with DSC. Can’t you run it just by itself? … with sufficient rights to the target system of course …
### Barried somewhere in here are all the pieces of this with no example or clear explanation:
# https://docs.ansible.com/ansible/2.5/user_guide/become.html#become-and-windows
Ansible.cfg
[all:vars]
ansible_connection=winrm
ansible_user=administrator
ansible_password=@Pa55w0rd
ansible_become_password=@Pa55w0rd
AWansible_port=5986
ansible_winrm_scheme=https
POWERSHELL_VERSION=5.1
Playbook.yml
---
- hosts: all
gather_facts: no
become_method: runas
tasks:
- name: Create directory structure
win_file:
path: C:\vsts\IA
state: directory
- name: Add FOD
ansible.windows.win_shell: |
Add-WindowsCapability -Online -Name ServerCore.AppCompatibility~~~~0.0.1.0
become: yes
become_user: administrator
- name: Test FOD
ansible.windows.win_shell: |
$WinCapObj = Get-WindowsCapability -Online -Name ServerCore.AppCompatibility~~~~0.0.1.0
Write-Output -InputObject "Current State of FOD:: $($WinCapObj.State)"
- name: Reboot if required
ansible.windows.win_reboot: