28 Days of DSC: Day 6 Nested Configurations3 min read

Hey Guys,

So today is Day 6, hope you’re all still with me and positive about implementing DSC in your environment. We are building up to something which is on the way to writing our own custom resources. Once you’ve got the hang of Nested Configurations, you can move onto Composite Resources. Then from there, you can move on to creating script based resources and maybe even class based resources if you’re feeling fancy.

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

But let’s not get ahead of ourselves.

Nested Configurations are to DSC what functions are to PowerShell. You can reuse them in your configuration script to save you typing the same thing over and over.

At the end of the day, you still come out with 1 MOF file per Node, and nobody would know the wiser, unless they looked at your script or your MOF. When you execute them on the Node, they even look like the “more complicated” composite resources.

Again, Microsoft does have a short post on these which you can find here. This post is mainly to remind you that they exist and provide a couple of real life scenarios for them.

Bare in mind I would generally write composite resources to do this job but we’ll get to that another day.

Definition

As you would imagine, the syntax is almost identical to a DSC Configuration. It differs only in one way and that is that is has no node block. It inherits it from the parent script. See below:

All this nested resource does is allow me to easily specify how I want my Nic to look and in the background it goes and calls all the other DSC Resources.

You can simplify the main config so much that perhaps you could train your support staff and juniors to update configurations. All the while knowing you are in control of how the resources are set.

Pretty neat right?!

Other Examples

Think about all the scripts and functions you’ve written today and how you could port them over and use the logic to handle DSC Resource configuration. I can imagine using Nested Resources for the following scenarios:

  • User deployment – AD, Mailbox, Skype, SharePoint etc
  • Nic Configurations
  • Disk Configurations
  • File Server Folder Structure and NTFS Permissions
  • Best Practice/Lockdown policies i.e. stopping services, settings reg keys on IIS Server or SQL
  • etc

This list is virtually endless, the more you automate the less time you have to spend doing tedious tasks. It seems obvious to be telling you this, but sometimes you don’t think that spending 5 minutes doing 1 job every now and then costs you a lot. But I imagine if you count up those minutes plus the piece of mind of knowing the system is as you want it (because that’s what DSC does) you’re really onto a winner!

I hope this has been useful post for you. The level and complexity is going to start to rise as we get into writing our own custom resources, so if this has all been stuff you’ve already know up until now, then just wait…the good stuff is coming.

The DSC Community is one of sharing, so let me know if you’ve already written your own Nested or Composite resources. Tweet me with you’re ideas about how you would use them in your environments using #28DaysOfDSC.

Thanks!

and Don’t Forget To Automate It!

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.