Chef + Custom DSC Resources


#1

Ohai Chef Community!

I’m planning on designing a cookbook that uses some custom DSC resources. Matt Wrock has an excellent example (https://github.com/mwrock/dsc_nugetserver) using dsc_* Chef resources, but the actual DSC resources all come from the DSC Resource Kit.

I’m looking for a few things in particular when it comes to using custom DSC resources:

  1. ?Do I need both Chef Server (host cookbooks) + DSC Pull Server (host custom DSC resources)?
  2. Is the use of a *.ps1 configuration file required when using DSC resources in cookbooks?
  3. Is it fair to draw comparisons of developing a DSC resource to developing an LWRP?
 *   If so, how are dependent DSC resources pulled in to a recipe for use?  LWRPs have the advantage of either being part of the cookbook itself or dependent cookbooks.

Thanks for any help/suggestions/support!

  • Curtis

?


#2

Hey Curtis,

With DSC resources you have two options (depending on what version of Chef you are running and what version of the Windows Management Framework or WMF).

Chef 11.16.0 introduced dsc_script which works with WMF 4 or greater. dsc_script can either embed a bit of DSC configuration syntax or point to an existing dsc configuration script.

https://docs.chef.io/resource_dsc_script.html

dsc_resource is newer and relies on WMF 5 (February preview). That is a more natural use of DSC from Chef, but relies on newer features that aren’t as far downlevel yet (2012 or 2012 R2).

https://docs.chef.io/resource_dsc_resource.html

Take a look at the github repo from my ChefConf demo: http://bit.ly/chefconf_dsc or my talk: http://bit.ly/chefconf2015_dsc_video

There are examples of dsc_script, dsc_resource, an equivalent recipe with just powershell_script, and the DSC configuration equivalent.

As far as custom resources themselves, you are responsible for getting the resources on the node. You could use remote_file, chocolatey, PowerShellGet, PSGet or any other method you can think of to stage the resources.

With some of the changes in WMF5, we may be able to also use a pull server to distribute resources, but I have to test that yet.

Steve


Steven Murawski
Community Software Development Engineer @ Chef
Microsoft MVP - PowerShell
http://stevenmurawski.com

On April 16, 2015 at 2:39:18 PM, Curtis Stewart (stewartc@vmware.com) wrote:

Ohai Chef Community!

I’m planning on designing a cookbook that uses some custom DSC resources. Matt Wrock has an excellent example (https://github.com/mwrock/dsc_nugetserver) using dsc_* Chef resources, but the actual DSC resources all come from the DSC Resource Kit.

I’m looking for a few things in particular when it comes to using custom DSC resources:

​Do I need both Chef Server (host cookbooks) + DSC Pull Server (host custom DSC resources)?
Is the use of a *.ps1 configuration file required when using DSC resources in cookbooks?
Is it fair to draw comparisons of developing a DSC resource to developing an LWRP?
If so, how are dependent DSC resources pulled in to a recipe for use? LWRPs have the advantage of either being part of the cookbook itself or dependent cookbooks.

Thanks for any help/suggestions/support!

  • Curtis