28 Days of DSC: Day 7 Composite Resources3 min read

Hey Guys,

Day 7, a whole week of DSC. Today we’re taking what we learnt yesterday with the Nested Configurations and utilizing it to write Composite Resources.

So what are Composite Resources? Their functionality is basically equal to that of the Nested Configurations we wrote yesterday. The only difference is that they are versioned and exist in a module. This makes it useful to package them and deploy using the PowerShell Gallery for example.

Structure

As with normal DSC Modules, their is the Module Manifest and DSCResources folder in the root. Inside the DSCResources folder exists a folder for each Resource you create regardless whether its Script, Composite or otherwise.

For Composite Resources, 2 files need to exist. Firstly, the .psd1 manifest and the .schema.psm1

If you’ve done created all that, you should have something like this.

The Code

The dftaiSQLSetup.psd1 looks as follows. Both these properties are mandatory.

Then in your schema.psm1 file, goes your Nested Conf…Composite Resource.

Here is an example of a Composite Resource for installing SQL. Beware, as with the Nested Configurations, the Node block isn’t necessary since it will be called from within DSC Configuration which is responsible for that part.

This is just another example of how easy it is to simplify the installation of an otherwise complex application like SQL by hiding all the “complexity” in your Composite Resources.

To confirm that everything is working and at least your syntax is correct. You can run the Get-DSCResource command and confirm the newly created resource is visible.

Looking at how we could use this Composite Resource in a configuration, we see just how much easier we’ve made our and potentially someone else’s life.

This should set you on your way to create your own composite resources. Right now, we haven’t learnt anything too complicated. All you’re doing is collecting up all of the pre-existing resources and nicely presenting them.

Tomorrow will be the beginning of learning how to create your own script resources from scratch.

If you’ve missed any of the other posts from the 28 Days of DSC series, check them out here.

If you have any questions or suggestions for topics to cover in the series, hit me up on twitter.

Thanks!

and Don’t Forget To Automate It!

Leave your comment