Download presentation
Presentation is loading. Please wait.
1
DevOps – Desired State Configuration –
Mohit K. Gupta DevOps – Desired State Configuration –
2
SQL Summit Annual International Conference November 6 -9 | Seattle, WA
2 Days of Pre-Cons 200+ sessions over 3 days Over 5,000 SQL Professionals Evening Networking Activities
3
Please Support Our Sponsors
4
Let’s Not Distract Others
Please silent your phone We can chat later Please don’t snore
5
Agenda Introduction to Desired State Configuration (DSC) Requirements
DSC v4 and DSC v5 DSC Terminology Development & Deployment DSC Resources
6
Introduction
7
Introduction DSC is a configuration management platform
Service and Application Agnostic Standards-based Distributed Benefits Ensures configuration Supports continuous deployment Prevents configuration drift Change control becomes a text file
8
Challenge 1: Deployment & Consistency
Manual deployment is neither repeatable nor consistent Dev, Test, Prod do not match Build scripts can break mid-stream
9
Challenge 2: Server Outage
Change happened somewhere Configuration drift
10
Imperative vs Declarative Language
Add-WindowsFeature Windows-Server-Backup Declarative Configuration BaseBuild { WindowsFeature Backup { Ensure = "Present" Name = "Windows-Server-Backup" }
11
Requirements
12
Operating System Requirements
WMF 4.0 WMF 5.0 Windows 7 Upgrade Windows 2008 R2 Windows 8 Windows 2012 Windows 8.1 Default Windows 2012 R2 Windows 10 Windows 2016 PowerShell DSC requires .NET Framework 4.5
13
Windows 2008 R2 Compatibility
Supports PowerShell DSC via WMF 4.0 or WMF 5.0 update Built-in resources will work Limited support for community resources
14
DSC v4 and DSC v5
15
DSC Command-Lets by Version
Name DSC v4 DSC v5 Configuration X Get-DscConfiguration Get-DscLocalConfigurationManager Get-DscResource New-DscCheckSum Restore-DscConfiguration Test-DscConfiguration Set-DscLocalConfigurationManager Start-DscConfiguration Remove-DscConfigurationDocument Stop-DscConfiguration Update-DscConfiguration Find-DscResource Get-DscConfigurationStatus Invoke-DscResource Publish-DscConfiguration Enable-DscDebug Disable-DscDebug
16
Demonstration - Deploy SQL Server -
17
DSC Terminology
18
Terminology Configuration File Built-In Resources MOF
Local Configuration Manager Push / Pull
19
Configuration File Configuration IISWebsite { Node Server1
WindowsFeature IIS Ensure = "Present" Name = "Web-Server" } WindowsFeature ASP Name = "Web-Asp-Net45"
20
Built-In Resources File Archive Environment Group Log Package Registry
Script Service User WindowsFeature WindowsProcess
21
MOF File MOF – Managed Object Format
Industry standard text file contain resource and configuration data. Consumed by WMI/CIM. localhost.mof
22
Local Configuration Manager (LCM)
The “DSC engine” Enforces configuration and consistency Can auto-correct a state that changes Settings to configure intervals, reboots, etc. Local Configuration Manager
23
LCM Properties Get-DscLocalConfigurationManager ConfigurationMode
ApplyOnly ApplyAndMonitor (Default) ApplyAndAutoCorrect ConfigurationModeFrequencyMins Interval to apply configuration RefreshFrequencyMins Interval to pull configuration RefreshMode Push Pull Disabled
24
Push / Pull Authoring Staging Nodes Config Pulled IIS Config Pulled
Server1 Config Pushed Config Pulled Server1.mof Server1 Configs Deployed Server1.mof Config Pulled IIS Server1.mof Server1 Configs Deployed Server1.mof File Share
25
LCM Example - Pull [DscLocalConfigurationManager()]
Configuration LCMPull { Node localhost Settings ActionAfterReboot = 'ContinueConfiguration' AllowModuleOverWrite = $True ConfigurationID = 'a019aeb4-27e0-4ae2-b2f9-edc0fc620338' ConfigurationMode = 'ApplyAndAutoCorrect' ConfigurationModeFrequencyMins = 15 RefreshFrequencyMins = 30 StatusRetentionTimeInDays = 7 RebootNodeIfNeeded = $True RefreshMode = 'Pull' } ConfigurationRepositoryWeb PullServer ServerURL = " AllowUnsecureConnection = $false
26
LCM Example - Push [DscLocalConfigurationManager()]
Configuration LCMPushv5 { Node localhost Settings ActionAfterReboot = 'ContinueConfiguration' AllowModuleOverWrite = $True ConfigurationMode = 'ApplyAndAutoCorrect' ConfigurationModeFrequencyMins = 15 RefreshFrequencyMins = 30 StatusRetentionTimeInDays = 7 RebootNodeIfNeeded = $True RefreshMode = 'Push' } LCMPushv5 Set-DSCLocalConfigurationManager -Path .\LCMPushv5
27
Development & Deployment
28
Quick Configuration – Snippets & Syntax
CTRL + J snippet for configuration. Get-DscResourceName -Syntax Copy and Paste
29
Quick Configuration - IntelliSense
Type the resource name and curly braces. CTRL+SPACE for IntelliSense. Use TAB completion for enumerated property values and DependsOn.
30
Quick Configuration - DependsOn
Configuration DependsOnExample { Import-DscResource -ModuleName PSDesiredStateConfiguration Node localhost { File DSCTempFolder { DestinationPath = 'C:\DSCTemp\' Ensure = 'Present' Type = 'Directory' } Archive ExtractZIP { Path = 'C:\InstallSource\LogParser.zip' Destination = 'C:\DSCTemp\logparser\' Force = $true DependsOn = '[File]DSCTempFolder' Package InstallLogParser { Ensure = 'Absent' Name = 'Log Parser 2.2' Path = 'C:\DSCTemp\logparser\logparser.msi' ProductId = '4AC23178-EEBC-4BAF-8CC0-AB15C8897AC9' DependsOn = '[Archive]ExtractZIP' The order of execution of resources is not guaranteed. Use the common property DependsOn to establish order in the format [Resource]Name.
31
Start-DscConfiguration
C:\Windows\System32\Configuration\ Start-DscConfiguration publishes and applies pending.mof 2. Renames current to previous previous.mof current.mof pending.mof 3. Renames pending to current
32
Start-DscConfiguration -UseExisting
1. Reapplies current.mof previous.mof current.mof
33
Restore-DscConfiguration
previous.mof current.mof pending.mof 1. PUSH mode only. Renames previous to pending
34
Remove-DscConfigurationDocument
Remove-DscConfigurationDocument -Stage Current Pending Previous previous.mof current.mof pending.mof Used to “unconfigure” DSC configuration, leaving the settings applied.
35
Query the Desired State
Test-DscConfiguration – true/false desired state Get-DscConfiguration – current state of configured resources Get-DscConfigurationStatus – Date & time, success or failure Get-DscConfigurationStatus -All – History of DSC events and status
36
DSC Resources
37
Resources A resource is PowerShell code that tells a node how to configure the settings Use property values as parameters Can express dependencies Deployed using PowerShell modules
38
Resource Types Built-In Resource Kit(s)
Community (ex. TechNet Script Center, GitHub) Custom
39
Key Command Lets Command Let Description Get-DscResource
Shows current installed resources on system. Can also be used to determine the resource syntax. Find-DscResource Find-Module Search for repositories online. Install-Module Save-Module Install the DSC Resource.
40
Resource Naming Conventions
Resource Name Meaning [ ]FileSystem This resource or other like it are built-in resources with no-prefix. [x]SQLServer Microsoft DSE Resource Kit, stands for eXperimental. Developed by Microsoft. [c]ResourceName Community Developed.
41
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.