Installing the DSC server

The following example is taken from the example provided by the PowerShell team in the xPSDesiredStateConfiguration module. Just as when we showed an example DSC configuration in the authoring phase, don't get too caught up on the following syntax. Examine the structure and how much this looks like a list for what we need. Running this on a target node sets up everything needed to make it a pull server, ready to go from the moment it is finished.

In the interest of showing an actual example, we are skipping several setup steps that you must complete in order to actually use the example. We will go into detail in Chapter 6Pulling DSC Configurations, with all steps required to make this work for you. Here, we aim to show you how easy it is to describe a set of disparate components and achieve a fully configured server out of them.

The first step is to make a text file called the SetupPullServer.ps1 file with the following content:

  # Declare our configuration here
Configuration SetupPullServer
{
# Import a DSCResource here. We will cover this more in chapter 3
Import-DSCResource -ModuleName xPSDesiredStateConfiguration

# Declare the node we are targeting
Node "localhost"
{
# Declare we need the DSC-Service installed
WindowsFeature DSCServiceFeature
{
Ensure = "Present"
Name = "DSC-Service"
}

# Declare what settings the pull server should have
xDscWebService PSDSCPullServer
{
Ensure = "Present"
State = "Started"
EndpointName = "PSDSCPullServer"
Port = 8080
CertificateThumbPrint = "AllowUnencryptedTraffic"
PhysicalPath = "$env:SystemDriveinetpubwwwrootPSDSCPullServer"
ModulePath = "$env:PROGRAMFILESWindowsPowerShellDscServiceModules"
ConfigurationPath = "$env:PROGRAMFILESWindowsPowerShellDscServiceConfiguration"
DependsOn = "[WindowsFeature]DSCServiceFeature"
}
}
}

The next step is to invoke the DSC Configuration cmdlet to produce an MOF file. By now, we don't need to show the output MOF file, as we have covered that already. We then run the Start-DscConfiguration cmdlet against the resulting folder and the pull server is set up. Remember, we will cover this in detail in Chapter 6, Pulling DSC Configurations.

A good thing to remember when you eventually try to use this DSC configuration script to make a DSC pull server is that you can't make a client operating system a pull server. If you are working on a Windows 8.1 or 10 desktop while trying out these examples, some of them might not work for you because you are on a desktop OS. For example, the WindowsFeature DSC resource works only on the server OS, whereas the WindowsOptionalFeature DSC resource operates on the desktop OS. You will have to check each DSC resource to find out what OS or platforms they support, just like you would have to check the release notes of the software to find out the supported system requirements.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset