SlideShare a Scribd company logo
Kok Hui Lew
Specialist Solution Architect
Automate Windows Environments
with Ansible and DSC
Agenda
● Windows Management with Ansible
● What is DSC?
● Why use DSC with Ansible?
● Where to use Ansible Windows Modules vs DSC
resources?
● Compare and contrast Windows Modules and
DSC resource examples
● Credential Management
● Example Playbooks
SIMPLE POWERFUL AGENTLESS
App deployment
Configuration management
Workflow orchestration
Network automation
Orchestrate the app lifecycle
Human readable automation
No special coding skills needed
Tasks executed in order
Usable by every team
Get productive quickly
Agentless architecture
Uses OpenSSH & WinRM
No agents to exploit or update
Get started immediately
More efficient & more secure
WHY ANSIBLE?
70+
Windows Modules
Use Ansible to deploy and manage Windows
systems and applications.
ANSIBLE WINDOWS AUTOMATION
ansible.com/windows
350+
Powershell DSC
resources
- hosts: new_servers
tasks:
- name: ensure common OS updates are current
win_updates:
register: update_result
- name: ensure domain membership
win_domain_membership:
dns_domain_name: contoso.corp
domain_admin_user: '{{ domain_admin_username }}'
domain_admin_password: '{{ domain_admin_password }}'
state: domain
register: domain_result
- name: reboot and wait for host if updates or domain change require it
win_reboot:
when: update_result.reboot_required or domain_result.reboot_required
- name: ensure local admin account exists
win_user:
name: localadmin
password: '{{ local_admin_password }}'
groups: Administrators
- name: ensure common tools are installed
win_chocolatey:
name: '{{ item }}'
with_items: ['sysinternals', 'googlechrome']
PLAYBOOK EXAMPLE: WINDOWS
What is DSC?
> Windows Management Platform built in
● Ships natively with Windows Server 2012
R2 and Windows 8.1 and newer
● Requires PowerShell v4 or greater
> Configuration based declarative model
● Define desired state in configuration
● DSC determines how to execute on target
> Push or Pull Architecture
Why Use DSC with Ansible?
Both declarative &
end-state oriented
Scale using Ansible
lightweight
architecture
Compliment each
other
Rich community
ecosystem for both
Ansible Tower
provides enterprise
capabilities
managing Windows
Extend end-to-end
use cases beyond
Windows
management
Where to use Ansible Windows Modules vs DSC resources?
Reasons for using an Ansible module over a DSC resource:
● The host does not support PowerShell v5.0, or it cannot easily be upgraded
● The DSC resource does not offer a feature present in an Ansible module
● DSC resources have limited check mode support, while some Ansible modules have better checks
● DSC resources do not support diff mode, while some Ansible modules do
● Custom resources require further installation steps to be run on the host beforehand, while
Ansible modules are in built-in to Ansible
Reasons for using a DSC resource over an Ansible module:
● The Ansible module does not support a feature present in a DSC resource
● There is no Ansible module available
- name: Install IIS Web-Server
win_feature:
name: Web-Server
state: present
restart: True
include_sub_features: True
include_management_tools: True
- name: Create IIS site
win_iis_website:
name: Ansible
state: started
physical_path: c:sitesAnsible
- name: Add HTTP webbinding to IIS
win_iis_webbinding:
name: Ansible
protocol: http
port: 8080
ip: '*'
state: present
Example playbooks with Ansible Modules vs DSC resources
- name: Install required DSC module
win_psmodule:
name: xWebAdministration
state: present
- name: Install IIS Web-Server
win_dsc:
resource_name: windowsfeature
name: Web-Server
- name: Create IIS site
win_dsc:
resource_name: xWebsite
Ensure: Present
Name: Ansible
State: Started
PhysicalPath: c:sitesAnsible
BindingInfo:
- Protocol: http
Port: 8080
IPAddress: '*'
- name: Install required DSC module
win_psmodule:
name: xWebAdministration
state: present
- name: Install IIS Web-Server
win_dsc:
resource_name: windowsfeature
name: Web-Server
- name: Create IIS site
win_dsc:
resource_name: xWebsite
Ensure: Present
Name: Ansible
State: Started
PhysicalPath: c:sitesAnsible
BindingInfo:
- Protocol: http
Port: 8080
IPAddress: '*'
Use win_dsc module vs Powershell
# Import the module
Import-DscResource -Module xWebAdministration,
PSDesiredStateConfiguration
Node $NodeName
{
# Install the IIS role
WindowsFeature IIS
{
Ensure = 'Present'
Name = 'Web-Server'
}
xWebsite DefaultSite
{
Ensure = 'Present'
Name = 'Ansible'
State = 'Started'
PhysicalPath = 'c:sitesAnsible'
DependsOn = '[WindowsFeature]IIS'
BindingInfo = MSFT_xWebBindingInformation
{
Protocol = 'http'
Port = '8080'
IPAddress = '*'
}
}
}
Handle Credentials with win_dsc Module
● By default win_dsc module uses SYSTEM account
● You can use PsDscRunAsCredential attribute to run as another user:
- name: use win_dsc with PsDscRunAsCredential to run as a different user
win_dsc:
resource_name: Registry
Ensure: Present
Key: HKEY_CURRENT_USERExampleKey
ValueName: TestValue
ValueData: TestData
PsDscRunAsCredential_username: '{{ ansible_user }}'
PsDscRunAsCredential_password: '{{ ansible_password }}'
no_log: true
Some Example DSC Resources
● Built-in:
○ Archive
○ File
○ Group
○ Package
○ WindowsFeature
○ And more..
● Custom resources provided by Microsoft and the community:
○ Domain Controller
○ IIS Web Site
○ SQL Server Cluster
○ Failover Cluster
○ DNS
○ And many more..
13 CONFIDENTIAL
Beyond Server Management - Rolling Update Example
Your applications and systems are more than
just collections of configurations. They’re a
finely tuned and ordered list of tasks and
processes that result in your working
application.
Ansible can do it all:
• Provisioning
• App Deployment
• Configuration Management
• Multi-tier Orchestration
How to obtain a list of Ansible Windows Modules and DSC Resources
● Ansible Modules:
○ https://docs.ansible.com/ansible/latest/modules/list_of_windows_modules.html
● Built-in DSC Resources:
○ https://docs.microsoft.com/en-us/powershell/dsc/builtinresource
○ Or run this powershell command: Find-DscResource
● DSC Resources on Github:
○ https://github.com/PowerShell/DscResources
● DSC Resources on Powershell Gallery:
○ https://www.powershellgallery.com
THANK YOU

More Related Content

PDF
06 network automationwithansible
PDF
05 security automationwithansible
PPT
HotLink DR Express
PPTX
Dutch VMUG 2010 PowerCLI Presentation
PDF
VMware Automation, PowerCLI presented at the Northern California PSUG
PPTX
Where did my day go?: Oracle Enterprise Manager 12c/13c Administration
PDF
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
PPTX
The Devopsification of Windows Server
06 network automationwithansible
05 security automationwithansible
HotLink DR Express
Dutch VMUG 2010 PowerCLI Presentation
VMware Automation, PowerCLI presented at the Northern California PSUG
Where did my day go?: Oracle Enterprise Manager 12c/13c Administration
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
The Devopsification of Windows Server

What's hot (19)

PPTX
IIS7 For Non IIS PFEs
PDF
Using Puppet with Self Service Provisioning
PDF
VMworld 2013: Part 1: Getting Started with vCenter Orchestrator
PDF
VMworld 2013: Part 2: How to Build a Self-Healing Data Center with vCenter Or...
PPTX
NetDevOps for the Network Dude: How to get started with API's, Ansible and Py...
PDF
VMworld 2013: vCenter Deep Dive
PPTX
PowerCLI Workshop
PPT
Mmik powershell dsc_slideshare_v1
PPTX
Lateral Movement with PowerShell
PDF
EVO-RAIL 2.0 Overview Deck
PPTX
WinOps Conf 2016 - Richard Siddaway - DevOps With Nano Server and Windows Con...
PDF
SCUGBE_Lowlands_Unite_2017_Servicing your new Windows workplace like a boss.
PDF
VMware Integrated OpenStack 2.0
PDF
How to build a Citrix infrastructure on AWS
PDF
VMworld 2013: Keep it Simple and Integrated - Out-of the Box Cross-System Aut...
PDF
IBM Think Session 3249 Watson Work Services Java SDK
PDF
ebk EVO-RAIL v104
PPTX
An Introduction to PowerShell for Security Assessments
PPTX
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
IIS7 For Non IIS PFEs
Using Puppet with Self Service Provisioning
VMworld 2013: Part 1: Getting Started with vCenter Orchestrator
VMworld 2013: Part 2: How to Build a Self-Healing Data Center with vCenter Or...
NetDevOps for the Network Dude: How to get started with API's, Ansible and Py...
VMworld 2013: vCenter Deep Dive
PowerCLI Workshop
Mmik powershell dsc_slideshare_v1
Lateral Movement with PowerShell
EVO-RAIL 2.0 Overview Deck
WinOps Conf 2016 - Richard Siddaway - DevOps With Nano Server and Windows Con...
SCUGBE_Lowlands_Unite_2017_Servicing your new Windows workplace like a boss.
VMware Integrated OpenStack 2.0
How to build a Citrix infrastructure on AWS
VMworld 2013: Keep it Simple and Integrated - Out-of the Box Cross-System Aut...
IBM Think Session 3249 Watson Work Services Java SDK
ebk EVO-RAIL v104
An Introduction to PowerShell for Security Assessments
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
Ad

Similar to 07 automate windowsenvironmentswithansibleanddsc (20)

PPT
Mmik_Powershell_DSC_Azure_DSC
PPTX
Morning Coffee - Windows Server 2016
PPTX
Private Cloud Academy: Backup and DPM 2010
PPTX
Just Another Word Press Weblog But More Cloudy
PPTX
Building & Managing Windows Azure
PPTX
Building & managing wa app wely
PPTX
3. Azure Virtual Machine Extension by Techserverglobal
PDF
Ansible Tutorial.pdf
PDF
Ansible - Hands on Training
PDF
Ansible Automation to Rule Them All
PPTX
WindowsAzureSDK1.7
PPTX
Deploying windows containers with kubernetes
PPTX
Automating That "Other" OS
PPTX
Automating Azure VMs with PowerShell
PPTX
WinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSC
PPTX
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
PPTX
Managing Azure Components Using Azure PowerShell
PPTX
Windows Azure & How to Deploy Wordress
PDF
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
PPT
Sdwest2008 V101 F Dpowerpoint Final
Mmik_Powershell_DSC_Azure_DSC
Morning Coffee - Windows Server 2016
Private Cloud Academy: Backup and DPM 2010
Just Another Word Press Weblog But More Cloudy
Building & Managing Windows Azure
Building & managing wa app wely
3. Azure Virtual Machine Extension by Techserverglobal
Ansible Tutorial.pdf
Ansible - Hands on Training
Ansible Automation to Rule Them All
WindowsAzureSDK1.7
Deploying windows containers with kubernetes
Automating That "Other" OS
Automating Azure VMs with PowerShell
WinOps Conf 2016 - Ed Wilson - Configuration Management with Azure DSC
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
Managing Azure Components Using Azure PowerShell
Windows Azure & How to Deploy Wordress
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
Sdwest2008 V101 F Dpowerpoint Final
Ad

More from Khairul Zebua (12)

PPTX
Ansible - From Zero to Hero.pptx
PPTX
Extending Agile with DevOps Mindset
PPTX
Get rid of obstacles with DevOps Mindset - IT Tech Talk #2 XL AXIATA
PPTX
Brace yourself alerts are coming (case study tokopedia)
PPTX
DevOps Monitoring and Alerting
PPTX
Ansible with Jenkins in a CI/CD Process
PPTX
DevOps Indonesia Presentation
PPTX
DevOps at Tokopedia - DevOps Indonesia
PDF
08 red hattrainingandcertification
PDF
04 accelerating businessvaluewithdevops
PDF
02 ansible automateskeynote-jakarta
PDF
03 ansible towerbestpractices-nicholas
Ansible - From Zero to Hero.pptx
Extending Agile with DevOps Mindset
Get rid of obstacles with DevOps Mindset - IT Tech Talk #2 XL AXIATA
Brace yourself alerts are coming (case study tokopedia)
DevOps Monitoring and Alerting
Ansible with Jenkins in a CI/CD Process
DevOps Indonesia Presentation
DevOps at Tokopedia - DevOps Indonesia
08 red hattrainingandcertification
04 accelerating businessvaluewithdevops
02 ansible automateskeynote-jakarta
03 ansible towerbestpractices-nicholas

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
cuic standard and advanced reporting.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
sap open course for s4hana steps from ECC to s4
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Reach Out and Touch Someone: Haptics and Empathic Computing
Advanced methodologies resolving dimensionality complications for autism neur...
cuic standard and advanced reporting.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Approach and Philosophy of On baking technology
Programs and apps: productivity, graphics, security and other tools
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation
Network Security Unit 5.pdf for BCA BBA.
Understanding_Digital_Forensics_Presentation.pptx
sap open course for s4hana steps from ECC to s4

07 automate windowsenvironmentswithansibleanddsc

  • 1. Kok Hui Lew Specialist Solution Architect Automate Windows Environments with Ansible and DSC
  • 2. Agenda ● Windows Management with Ansible ● What is DSC? ● Why use DSC with Ansible? ● Where to use Ansible Windows Modules vs DSC resources? ● Compare and contrast Windows Modules and DSC resource examples ● Credential Management ● Example Playbooks
  • 3. SIMPLE POWERFUL AGENTLESS App deployment Configuration management Workflow orchestration Network automation Orchestrate the app lifecycle Human readable automation No special coding skills needed Tasks executed in order Usable by every team Get productive quickly Agentless architecture Uses OpenSSH & WinRM No agents to exploit or update Get started immediately More efficient & more secure WHY ANSIBLE?
  • 4. 70+ Windows Modules Use Ansible to deploy and manage Windows systems and applications. ANSIBLE WINDOWS AUTOMATION ansible.com/windows 350+ Powershell DSC resources
  • 5. - hosts: new_servers tasks: - name: ensure common OS updates are current win_updates: register: update_result - name: ensure domain membership win_domain_membership: dns_domain_name: contoso.corp domain_admin_user: '{{ domain_admin_username }}' domain_admin_password: '{{ domain_admin_password }}' state: domain register: domain_result - name: reboot and wait for host if updates or domain change require it win_reboot: when: update_result.reboot_required or domain_result.reboot_required - name: ensure local admin account exists win_user: name: localadmin password: '{{ local_admin_password }}' groups: Administrators - name: ensure common tools are installed win_chocolatey: name: '{{ item }}' with_items: ['sysinternals', 'googlechrome'] PLAYBOOK EXAMPLE: WINDOWS
  • 6. What is DSC? > Windows Management Platform built in ● Ships natively with Windows Server 2012 R2 and Windows 8.1 and newer ● Requires PowerShell v4 or greater > Configuration based declarative model ● Define desired state in configuration ● DSC determines how to execute on target > Push or Pull Architecture
  • 7. Why Use DSC with Ansible? Both declarative & end-state oriented Scale using Ansible lightweight architecture Compliment each other Rich community ecosystem for both Ansible Tower provides enterprise capabilities managing Windows Extend end-to-end use cases beyond Windows management
  • 8. Where to use Ansible Windows Modules vs DSC resources? Reasons for using an Ansible module over a DSC resource: ● The host does not support PowerShell v5.0, or it cannot easily be upgraded ● The DSC resource does not offer a feature present in an Ansible module ● DSC resources have limited check mode support, while some Ansible modules have better checks ● DSC resources do not support diff mode, while some Ansible modules do ● Custom resources require further installation steps to be run on the host beforehand, while Ansible modules are in built-in to Ansible Reasons for using a DSC resource over an Ansible module: ● The Ansible module does not support a feature present in a DSC resource ● There is no Ansible module available
  • 9. - name: Install IIS Web-Server win_feature: name: Web-Server state: present restart: True include_sub_features: True include_management_tools: True - name: Create IIS site win_iis_website: name: Ansible state: started physical_path: c:sitesAnsible - name: Add HTTP webbinding to IIS win_iis_webbinding: name: Ansible protocol: http port: 8080 ip: '*' state: present Example playbooks with Ansible Modules vs DSC resources - name: Install required DSC module win_psmodule: name: xWebAdministration state: present - name: Install IIS Web-Server win_dsc: resource_name: windowsfeature name: Web-Server - name: Create IIS site win_dsc: resource_name: xWebsite Ensure: Present Name: Ansible State: Started PhysicalPath: c:sitesAnsible BindingInfo: - Protocol: http Port: 8080 IPAddress: '*'
  • 10. - name: Install required DSC module win_psmodule: name: xWebAdministration state: present - name: Install IIS Web-Server win_dsc: resource_name: windowsfeature name: Web-Server - name: Create IIS site win_dsc: resource_name: xWebsite Ensure: Present Name: Ansible State: Started PhysicalPath: c:sitesAnsible BindingInfo: - Protocol: http Port: 8080 IPAddress: '*' Use win_dsc module vs Powershell # Import the module Import-DscResource -Module xWebAdministration, PSDesiredStateConfiguration Node $NodeName { # Install the IIS role WindowsFeature IIS { Ensure = 'Present' Name = 'Web-Server' } xWebsite DefaultSite { Ensure = 'Present' Name = 'Ansible' State = 'Started' PhysicalPath = 'c:sitesAnsible' DependsOn = '[WindowsFeature]IIS' BindingInfo = MSFT_xWebBindingInformation { Protocol = 'http' Port = '8080' IPAddress = '*' } } }
  • 11. Handle Credentials with win_dsc Module ● By default win_dsc module uses SYSTEM account ● You can use PsDscRunAsCredential attribute to run as another user: - name: use win_dsc with PsDscRunAsCredential to run as a different user win_dsc: resource_name: Registry Ensure: Present Key: HKEY_CURRENT_USERExampleKey ValueName: TestValue ValueData: TestData PsDscRunAsCredential_username: '{{ ansible_user }}' PsDscRunAsCredential_password: '{{ ansible_password }}' no_log: true
  • 12. Some Example DSC Resources ● Built-in: ○ Archive ○ File ○ Group ○ Package ○ WindowsFeature ○ And more.. ● Custom resources provided by Microsoft and the community: ○ Domain Controller ○ IIS Web Site ○ SQL Server Cluster ○ Failover Cluster ○ DNS ○ And many more..
  • 13. 13 CONFIDENTIAL Beyond Server Management - Rolling Update Example Your applications and systems are more than just collections of configurations. They’re a finely tuned and ordered list of tasks and processes that result in your working application. Ansible can do it all: • Provisioning • App Deployment • Configuration Management • Multi-tier Orchestration
  • 14. How to obtain a list of Ansible Windows Modules and DSC Resources ● Ansible Modules: ○ https://docs.ansible.com/ansible/latest/modules/list_of_windows_modules.html ● Built-in DSC Resources: ○ https://docs.microsoft.com/en-us/powershell/dsc/builtinresource ○ Or run this powershell command: Find-DscResource ● DSC Resources on Github: ○ https://github.com/PowerShell/DscResources ● DSC Resources on Powershell Gallery: ○ https://www.powershellgallery.com