PowerShell v4 Desired State Configuration

15

Click here to load reader

description

Microsoft very recently announced that Windows Server 2012 R2 and PowerShell v4 will ship Desired State Configuration as mechanism to declaratively define the components to be installed + configured on a Windows system, and then automatically apply that state to a set of machines or detect variations in existing deployments. Jason will talk about how it will work, how you will be able to use it, and what you can do today to prepare.

Transcript of PowerShell v4 Desired State Configuration

Page 1: PowerShell v4 Desired State Configuration

PowerShell v4

Desired State Configuration

Page 2: PowerShell v4 Desired State Configuration

Windows does not work that way!

•Win32 API•COM•WMI•.NET

Page 3: PowerShell v4 Desired State Configuration

PowerShell is …

• .NET underneath• Structured data and behaviours• Objects in, objects out• A dynamic COM client• A WMI/CIM native• … capable of text manipulation and Regular Expressions too

Page 4: PowerShell v4 Desired State Configuration

PowerShell Desired State Configuration is …• New language KeywordsKeywords to declaratively define ConfigurationsConfigurations• Configurations that compile to Managed Object Format (MOF)• DSC Providers DSC Providers to apply Configurations to ResourcesResources• New Cmdlets Cmdlets to test, apply, and restore Configurations on demand• Local Configuration Manager Local Configuration Manager to maintain config and PullPull updates• DSC Service DSC Service to host Configurations and Providers centrally for Pull• Available in-the-box with Windows Server 2012 R2 on October 18th

Page 5: PowerShell v4 Desired State Configuration

Built-in Resources include …

•Archive• Environment• File•Group• Log•Package

•WindowsProcess•Registry•WindowsFeature• Script• Service•User

Page 6: PowerShell v4 Desired State Configuration

Configuration DemoConfig {param (…)

Node localhost {

WindowsFeature Telnet {Ensure = 'Present' # or 'Absent'Name = 'Telnet-Client'

}}

}

Page 7: PowerShell v4 Desired State Configuration

instance of MSFT_RoleResource as $MSFT_RoleResource1ref{

ResourceID = "[WindowsFeature]Telnet";Ensure = "Present";SourceInfo = "::6::9::WindowsFeature";Name = "Telnet-Client";ModuleName = "MSFT_RoleResource";ModuleVersion = "1.0";

};

instance of OMI_ConfigurationDocument { … };

Page 8: PowerShell v4 Desired State Configuration

Local Configuration Manager

• Responsible for validating and applying configuration• Runs under the context of the SYSTEM account• Only Administrators can submit configuration• Defaults to running in Push mode on a clean OS / PSv4 install• Supports Pull mode via file share or web service• Pull mode handles custom Resource Provider deployment• A single MOF file must encompass all the configuration

Page 9: PowerShell v4 Desired State Configuration

PS /> Start-DscConfiguration

Page 10: PowerShell v4 Desired State Configuration

DSC Service

• An IIS-hosted OData web service• An optional feature in Server 2012 R2• Consists of two components:• The Pull Server• The Compliance Server

• No documentation yet

Page 11: PowerShell v4 Desired State Configuration

Custom DSC Providers

• Custom Resources are a formalisation of the Script Resource:• Get-TargetResource• Set-TargetResource• Test-TargetResource

• MOF Schema with a Key and properties• Existing examples:• DHCP (by @gpduck)• Hosts file (on github.com/PowerShellOrg/DSC)• Website (in the Hands-On Lab)

• Expect to develop custom resources as an early adopter

Page 12: PowerShell v4 Desired State Configuration

What about System Center?

• Configuration Manager is expected to be used by the Enterprise. DSC is expected to be used for Azure and for DevOps.• Virtual Machine Manager 2012 R2 can call DSC during

provisioning

Page 13: PowerShell v4 Desired State Configuration

With DSC, Windows becomes text files•Versionable• Indexable•Auditable• Self-documenting

Page 14: PowerShell v4 Desired State Configuration

Without DSC, follow the same principals• Idempotency• Separate intent from implementation• Separate environmental configuration differences• Server names• Credentials• Number machines per role

Page 15: PowerShell v4 Desired State Configuration

Jason Stangroome@jstangroome

blog.stangroome.com