Node

The next variable to cover is the $Node variable. $Node refers to the specific target node being worked on. It is a particular entry inside the $AllNodes array. Think of the $Node variable as an iteration on the values of the $AllNodes array, so anything inside this variable applies to one node at a time. This doesn't mean that execution of the contents of the $Node variable happens serially across target nodes; it is more a mental model to keep in mind when looking at the configuration scripts.

The $Node variable is a single hash table that has all the values you provided for that target node in your $AllNodes array. For example, we will use the following piece of code pulled from an example we'll use later on, to show how to use ConfigurationData inside our DSC configuration scripts:

Package InstallExampleSoftware
{
Ensure = "Present"
Name = $Node.ExampleSoftware.Name
ProductId = $Node.ExampleSoftware.ProductId
Path = $Node.ExampleSoftware.Path
}

It uses the data we define in ConfigurationData that we pass to the DSC configuration block. Using the preceding example, this is how we would define it:

@{
AllNodes = @(
@{
NodeName = "server1"
ExampleSoftware = @{
Name = "ExampleSoftware"
ProductId = "{b652663b-867c-4d93-bc14-8ecb0b61cfb0}"
SourcePath = "c:packages hesoftware.msi"
}
},
@{
NodeName = "server2"
}
);
}

This is the granular level we were just talking about in the $AllNodes section. This hash table is free form and can contain any information you want. It can contain nested hash tables or typed information. This is the place where you can fully describe the state of each server as you want it to be. Anything is up for grabs to include, but be careful as there are some rules and syntax you must know when trying to place information here; we will cover this in the Defining a DSC configuration data file section later in this chapter.

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

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