Desired State Configuration (DSC) is a feature of the Windows Management Framework v4 (many folks just call this PowerShell v4) which ships natively with Server 2012 R2 and Windows 8.1.
One thing to be clear on; DSC is not a single thing, it is a feature with different components. And this is an exploration of the main components at a high level to understand all of the concepts. Lets take a look at the moving parts that work together to enable DSC; the configuration keyword, a configuration, the Local Configuration Manager, resource providers, WinRM, PowerShell.
Before I get to deep into this I want to thank some fellow MVPs who have the award area of PowerShell for helping me with a few things as I worked through my understanding. I also want to thank the product team at MSFT for taking some time to sit with me and talk as a customer, helping give me more insight and giving them feedback into my scenarios and my customers’ scenarios.
The MVP community is great at producing resources and communicating out. Here are a few good resources:
- The DSC Book – A free resource from Don Jones and Steve Murarwski
- Windows PowerShell Desired State Configuration Revealed – from Ravikanth Chaganti
- PowerShell.org and PowerShellMagazine.com
Lets begin with the first stumbling block: Windows Remote Management (WinRM)
WinRM is required for DSC to receive and process configurations in a Push or Pull model (more about those later). Let me say here that if you are learning and follow any of the examples and apply a configuration; you will likely be applying a configuration interactively at the console (Push model). This will simply work out of the box if your target is Server 2012 R2. This is will simply fail out of the box if your target is Windows 8.1.
The difference? WinRM is enabled by default on Server and disabled by default on Client. So plan accordingly, or you will get error messages that you cannot apply your configuration because WinRM is not running.
PowerShell is the enabling technology and the owning product team at MSFT. If you are following recent PowerShell developments you have heard about OMI. And if you recently listen to Jeffry Snover talk about DSC you will hear mention of the Monad Manifesto, and that DSC is a component of the original Monad vision that is realized as ‘PowerShell’.
The Local Configuration Manager (LCM) can be thought of as the agent that makes it happen.
The LCM is essentially a service that takes the configuration, parses the configuration, sorts out the dependencies defined in the configuration, then makes that configuration happen. The key thing to understand is that all configuration are applied in the security context of the Local System. By default this allows no access to anything outside the machine, and can only act on objects that are local to the machine. For example; if a software package is being installed, that package must be local to the machine, or the machine must be able to access it within its security context.
Did you get that DSC is not a management layer? It is the lowest level execution engine / the enabler / the Riker to Picard (this is the analogy that the PowerShell team originally used).
In fact companies like Puppet and Chef are already taking advantage of DSC, using it to do their dirty work and are not threatened by it. And MSFT has enabled DSC as a VM Extension to apply configurations to Azure IaaS virtual machines through the API. Also, if you have SCVMM Service Templates or Windows Azure Pack Gallery Items; they too can use DSC as then end engine that performs the configuration actions.
Now we get down to the configuration itself.
The configuration is a MOF format document that defines the end result that the Local Configuration Manager must make happen. The MOF can be generated in a number of ways, but the easiest by far is to use the configuration keyword within a PowerShell script.
The configuration keyword is nearly the last enabler. You can call it within a script to define this special thing called a configuration. That is then realized as a MOF file. That is in turn applied to the LCM. Which in turn makes it so.
Now, there is the last enabler. The resource provider.
These are special modules – they are task built and their whole job is to Get the state of some resource, Set the state of some resource, and Test the state of some resource. The resource is the item being manipulated.
There are resource providers that are built into the OS; archive (handling ZIP files), file (manipulating files), package (installing / uninstalling packages), and so on. Each one of these is declared in a configuration with the state you desire it to have. And you can perform actions such as unzipping an archive, copying a file to a specific path, installing / uninstalling a specific MSI, and so on.
There is also a framework for custom resource providers. This is to extend support to third party applications such as XenDesktop, or to allow the community to build modules that do far more than the ones provided by MSFT.
There are also MSFT provided ‘x’ resource providers. But frankly, I am hoping that PowerShell v5 will include many of these at a release quality level. Until then, they are just like any other custom resource.
Like what you read here? Read other posts about Desired State Configuration