Configuring the DSC local configuration manager

The LCM is a key component of DSC. LCM is a Windows service that runs on each DSC target node, and is responsible for receiving configuration information and ensuring that the node is configured in the desired state (and remains that way).

DSC has two mechanisms for the desired state delivery: push and pull. The earlier recipes in this chapter demonstrated the push model: you create a configuration and its related MOF file on one node and push that configuration to another node. In the pull model, you configure the node with details of where and how to find a pull server. Once configured, a node can pull configurations from the configured pull server. In both cases, it is the LCM that performs the actual configuration.

The way the LCM works changed in PowerShell version 5. In this recipe, which you run on SRV2, you configure the LCM (based on the PowerShell V5 mechanism) on SRV2 and set up SRV2 to pull the DSC configuration from SRV1 which you set up as an SMB pull server. You set up SRV1 itself in the next recipe, Implementing an SMB pull server.

Getting ready

In this recipe, you use a special type of configuration known as a metaconfiguration. You use the metaconfiguration statement to configure DSC on a node. You run this recipe on the target node, SRV2.

How to do it…

  1. Remove the local MOF files and configurations on SRV2 and ensure that C:DSC exists using the following code:
    $RIHT =@{
      Path        = 'C:WindowsSystem32configuration*.mof'
      ErrorAction = 'SilentlyContinue'
    }
    Get-Childitem @RIHT |
      Remove-Item @RIHT -Force
    $EASC = @{
      ErrorAction = 'SilentlyContinue'}
    New-Item -Path c:DSC -ItemType Directory @EASC | 
      Out-Null
  2. Get the default settings for LCM using the following code:
    Get-DscLocalConfigurationManager |
      Format-List -Property ActionafterReboot,
                            AllowModuleOverwrite,
                            Configuration*,
                            LCMState,
                            PartialConfigurations,
                            Reboot*,
                            Refresh*,
                            Report*,
                            Resource*
  3. Create the metaconfiguration for this host using the following code:
    Configuration SRV2LcmConfig {
      Node Localhost{
        LocalConfigurationManager {
          ConfigurationMode              = 'ApplyOnly'
          RebootNodeIfNeeded             = $true    
        }
      }
    }
  4. Run the configuration and create the MOF file using the following code:
    SRV2LcmConfig -OutputPath C:DSC 
  5. Update the LCM configuration based on the MOF using the following code:
    Set-DscLocalConfigurationManager -Path c:DSC -Verbose
  6. Check the updated properties for the LCM using the following code:
    Get-DscLocalConfigurationManager |
      Format-List -Property ActionafterReboot,
                            AllowModuleOverwrite,
                            Configuration*,
                            LCMState,
                            PartialConfigurations,
                            Reboot*,
                            Refresh*,
                            Report*,
                            Resource*

How it works

In step 1, you remove any existing DSC configuration MOF files for this node and ensure that the C:DSC folder exists on SRV2. There is no output from this step.

In step 2, you retrieve and view some of the properties of the DSC LCM on SRV2, which looks like this:

How it works

In step 3, you create a configuration statement to configure the LCM of SRV2. There is no output from this step.

In step 4, you execute the configuration to create the MOF file, which looks like this:

How it works

In step 5, you apply the LCM's configuration and, using the -Verbose switch. You get the following output:

How it works

In the final step of this recipe, step 6, you review the key properties of the LCM of SRV2, which looks like this:

How it works

There's more...

This recipe demonstrated the basics of configuring the LCM on a node. To set up a pull server, as you see in the remaining recipes in this chapter, you need to update the LCM further.

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

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