Adding DSC resources to a pull server

In the push mode, you can place a DSC resource module folder in a PowerShell module path (any of the paths defined in the $env:PSModulePath path), and things will work out fine. A pull server requires that DSC resources be placed in a specific directory and compressed into a ZIP format with a specific name in order for the pull server to recognize and be able to transfer the resource to the target node.

Here is our example DSC resource in a folder on our system. We are using the experimental xPSDesiredStateConfiguration resource provided by Microsoft, but these steps can apply to your custom resources as well:

    PS C:Examples> ls .

Directory: C:Examples

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 5/20/2015 10:52 PM xPSDesiredStateConfiguration

The first step is to compress the DSC resource folder into a ZIP file. You may be tempted to use the .NET System.IO.Compression.Zipfile classes to compress the folder to a ZIP file. In DSC V4, you cannot use these classes as they create a ZIP file that the LCM cannot read correctly. This is a fault in the DSC code that reads the archive files. However, in DSC V5, they have fixed this so that you can still use System.IO.Compression.zipfile. A potentially easier option in PowerShell V5 is to use the built-in Compress-Archive cmdlet to accomplish this. The only way to make a ZIP file for DSC V4 is to use either the built-in compression facility in Windows Explorer, a third-party utility such as 7-Zip, or the COM Shell.Application object in a script:

    PS C:Examples> ls .

Directory: C:Examples

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 5/20/2015 10:52 PM xPSDesiredStateConfiguration
d---- 5/20/2015 10:52 PM xPSDesiredStateConfiguration.zip

Once you have your ZIP file, we rename the file to MODULENAME_#.#.#.#.zip, where MODULENAME is the official name of the module and #.#.#.# refers to the version of the DSC resource module we are working with.

If you start getting confused with version numbers, folder structures, and deployment folders, fear not. We will cover DSC resource internals in more detail in Chapter 5, Pushing DSC Configurations, and deployment internals in Chapter 6, Pulling DSC Configurations.

This version is not the version of the DSC resource inside the module but the version of the DSC resource root module. You will find the correct version in the top-level psd1 file inside the root directory of the module.

Let's take a look at the following example:

    PS C:Examples> ls .

Directory: C:Examples

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 5/20/2015 10:52 PM xPSDesiredStateConfiguration
d---- 5/20/2015 10:52 PM xPSDesiredStateConfiguration_3.2.0.0.zip

As with MOF files, DSC needs a checksum in order to identify each DSC resource. The next step is to run the New-DscCheckSum cmdlet against our ZIP file and receive our checksum:

    PS C:Examples> New-DSCCheckSum -ConfigurationPath .xPSDesiredStateConfiguration_3.2.0.0.zip -OutPath . -Verbose
VERBOSE: Create checksum file 'C:ExamplesxPSDesiredStateConfiguration _3.2.0.0.zip.checksum'

PS C:Examples> ls .

Directory: C:TestExample

Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 5/21/2015 10:52 PM 1136 xPSDesiredStateConfiguration _3.2.0.0.zip
-a--- 5/22/2015 10:52 PM 64 xPSDesiredStateConfiguration _3.2.0.0.zip.checksum

The final step is to copy the ZIP file and checksum file up to the C:Program FilesWindowsPowerShellDscServiceModules path on the pull server.

In order to make the previous steps easier, Microsoft published a set of PowerShell scripts in the xPSDesiredStateConfiguration DSC resource to automate these steps. We will cover how to use this in Chapter 6, Pulling DSC Configurations.

Once completed, the previous steps provide a working pull server. You configure your target nodes using the steps outlined in the previous section on LCM, and your target nodes will start pulling configurations. If you have more questions about this or want a more automated solution to making your pull server and adding your target nodes, we will be covering this in Chapter 6, Pulling DSC Configurations.

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

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