DSC is a feature built into the Windows Operating System.
It’s based on the standards like CIMS and WS-Management remote management
offered by the operating system. With DSC you can move to a way of
configuration management where you can create a script that defines how the
state of the server should be instead of defining how to make the server in the
desired state. That means, DSC is more of a declarative syntax than an
imperative one. This makes DSC scripts/ configurations easy to understand and
maintain by the operations.
A sample DSC configuration for configuring the web
applications in a SharePoint farm looks like:
Configuration SPSiteCollectionConfig {
param($nodes)
Import-DscResource -ModuleName xDSC_SPSiteCollection
Import-DscResource -ModuleName xDSC_SPWebApplication
Node ($nodes) {
xSPWebApplication WebApplication{
WebApplication = "WebApplication MYWebApp"
Ensure = "On"
}
SPSiteCollection SiteCollection {
SiteUrl = 'http://MYWEBAPP.com/newSite'
SiteName = 'New Site'
SiteTemplate = 'BLANKINTERNET#2'
ContentDatabaseName = 'CONTENT_NEWSite'
Language = '1033'
Ensure = 'Present'
DependsOn = "[xSPWebApplication] WebApplication"
}
}
}
SPSiteCollectionConfig
The
Configuration script start with a Configuration block which is used to
give the configuration a meaningful name. The configuration keyword is the core
component of DSC that defines the desired configuration of a target system. Following
the Configuration keyword, the Node keyword is used to specify the target
system/ systems on which the configuration should be applied by the LCM. You can
also parameterize the values that are passed to the Node keyword if you want to
decide the target systems at a later point of time. Later you can pass the
target systems values to the configuration when you want to create a MOF file
out of the configuration created.
Within the node is a state of a DSC Resource. The DSC
resource module is what takes care of the how part of the configuration
management. The DSC resource modules are implemented or written in imperative
style, which means the resource module implements all the necessary details to
manage the configuration settings of an entity. However, the DSC configuration
makes it possible to abstract those imperative details from the end user, using
a declarative configuration script.
We now have to translate that into a format that the DSC
Local Configuration Manager or the DSC Engine can understand. This is the
Managed Object Format (MOF) representation of the configuration script. We can
generate the MOF representation of the configuration script by simply loading
the configuration into memory and then calling the configuration.
In our
example we added the name of the configuration at the end of the script. This
will ensure that the script when executed will generate the MOF files for each
node and store it in the folder that has the same name as the configuration.
Once you have the MOF files
generated you can execute them using the PUSH mode by calling the
Start-DSCConfiguration cmdlet
No comments:
Post a Comment