Desired State Configuration (DSC)… Ring any bells? No? It should by now. Although it isn’t a technology or concept thought up by Citrix, it is still very much applicable to Citrix components and infrastructures. DCS is a (still relatively) new management platform for Windows PowerShell allowing you to configure, apply and maintain a certain desired state (duh) on a single or multiple machine(s). A desired state can be anything related to software installation and configuration, the management of files and folders, registry entries, local group and account management, adding and removing server roles and the list goes on. Best thing is, as soon as something changes DSC will step in and correct it for you, preserving the desired state. DSC is a PowerShell extension and ships with Windows Server 2012 R2 and Windows 8.1. Let’s have a closer look at what is needed.
Simple, but skills are needed
Although the idea behind DSC is relatively straightforward, you do need to have some specific PowerShell skills to get things going. Initially you will use PowerShell to write a configuration script which, when executed, will generate a so-called MOF file. This file will hold the actual desired state configuration. MOF stand for Managed Object Format. What happens is, when executing the PS script the configuration (desired state) will be build, or written, in memory before being compiled into a MOF file. This is called the authoring phase.
Due note that MOF files can be created in other ways as well, third party tooling or other languages are also available. For example, a simple text editor can also be used. PowerShell v4 just makes it easier by adding declarative syntax extensions and IntelliSense. An end to a means, so to speak.
The MOF file is what will eventually be deployed, or pushed out, to the actual machine(s), applying the desired state. Once a machine has its desired state applied, you can re-apply your configuration as many times over as you feel fit, ensuring (monitoring) that the machine, or machines, will continue to keep their desired state. This is referred to as the deployment phase.
When a configuration is being re-applied it will only change the settings that do not match the desired state in the MOF file, everything else will simply get skipped. If you are already familiar with PowerShell this will probably be an easy step to take, getting started with DSC I mean. If not, then it might take some time to get your head around this. But when you do, you will have another Powerful automation tool at your disposal, free and very flexible. No agents needed and you can use it on-permissies as well as in your cloud deployments, supporting multiple frameworks.
You won’t have to start from scratch
Of course you’ll get some help, DCS works with so called recourse providers (modules), which contain the necessary resources to help build your PowerShell configuration script(s).
To start, there are twelve (build-in) resource providers offered by Microsoft, more information can be found in the TechNet Script center. These providers enable you to configure roles and features, copy files, create registry entries, manage services, create local users and groups, etc. And if that isn’t enough there are a few extra sets of DSC resource kits available (these are referred to as waves) extending your modules and configuration resources toolbox even further.
Custom resource providers
You also have the option to build your own custom PowerShell Desired Sate configuration resources. For this you will need to have, at least, a basic understanding on how to create PowerShell functions, basic Windows PowerShell providers and how to work with DSC providers in configuration scripts in general. If you would like to know more, check this page.
Not that long ago Citrix released their own custom resource provider, they named it, the XenDesktop Desired State Configuration resource provider Tech Preview. You can read all about it here. Although it may not sound very sexy and it isn’t a hot topic at this time it is definitely something to keep an eye on and perhaps worth investing some time in, to see what I might do for you. I’m pretty sure that we will see and hear a lot more on this in the months / years to come.
What you will need
PowerShell 4.0, or the Windows Management Framework 4.0, is needed to be able to utilize DSC. By default PS / WMF 4.0 are part of Windows Server 2012 R2 and Windows 8.1. Windows 7 and Windows Server 2008R2 are also supported but additional installation steps will be needed.
WMF and/or PS 4.0 can’t be installed in Windows 8.
You will need to be a local Administrator and WMF / PS 4.0 must be installed on all machines involved in the process. So the machine on which you create / compile the configuration script / MOF file as well as the machines to which the desired state gets applied.
In theory it works like this:
- Create a PowerShell configuration script, defining the desired state.
- Execute the configuration file.
- MOF file gets generated. It will contain what to install, which roles, how to configure, pre-checks etc…
- The MOF file gets deployed to one or multiple machines. This can be done in two ways, using the push or pull method.
- The push method (most used) uses the Start-DscConfiguration CMDlet to push out the MOF file to the target node(s).
- Using the pull method we would need to setup an http or https web server or a SMB file server for pull purposes.
Although I haven’t showed you how to actually use and apply DSC, I still hope this article helped you in understanding its capabilities, what is needed to get started and which steps are involved to get from a to b. I don’t think it will be too hard to come up with a valid use case.