Published on 21 March 2018 by

We are pleased to introduce the Puppet dsc_lite module, a new approach for declaring Desired State Configuration (DSC) syntax in Puppet manifests — an alternative to our original Puppet dsc module.

Depending on what you want to achieve, one module might be better suited to you than the other. Below we share some ideas to help you decide which approach is best for you.

Why try the new dsc_lite module

The dsc_lite module is a lighter weight version of the Puppet dsc module, providing more flexibility for advanced users. It allows you to manage target nodes using DSC resources by using a generalized Puppet call.

The main benefits of dsc_lite include:

  • It has the ability to use Managed Object Format (MOF)-based or your own custom DSC resources without our compilation steps — a huge benefit over the orginal dsc module. While the dsc module could use any of these DSC resources, it required you to run a rake build task to build the Puppet types. Due to the many varied places to get DSC resources, this parsing was prone to errors. The dsc_lite module does not require any build steps.
  • It allows you to use any DSC resources that are compatible with Invoke-DscResource, rather than only being able to use those bundled with the Puppet dsc module — allowing you to use those class-based DSC resources as well as MOF-based DSC resources.
  • It has the ability to independently deploy these DSC resources. This allows you to use whatever mechanism you want to deploy these, with whatever version you need, without waiting for our release cadence.
  • It has the ability to use class-based DSC resources. The original dsc module parsed the MOF schemas to build the Puppet types, but could not read class-based DSC Resources.
  • It has syntax similar to DSC reduces type ceremony, which reduces cognitive load when translating DSC syntax to Puppet syntax. This allows you to copy and paste the DSC declaration into a dsc_lite declaration, with only minor edits. The original dsc module would have required you to edit each DSC resource parameter declaration.

To showcase this, let’s look at a DSC resource declaration:

File fruit_file {
  Ensure          = 'Present'
  DestinationPath = 'C:\Fruit.txt'
  Type            = 'File'
  Contents        = 'Apple, Banana, Cherry.'
}

This is a normal declaration that sets the content of a file using the File DSC Resource. If we were using the original dsc module, we would modify it like this:

dsc_file {'fruit_file':
  dsc_ensure          => 'Present',
  dsc_destinationpath => 'C:\\Fruit.txt',
  dsc_type            => 'File',
  dsc_contents        => 'Apple, Banana, Cherry.',
}

Notice that we have to put dsc_ in front of the type, as well as in front of every parameter. It looks the same, but requires a bit of work to accomplish. Compare this with the syntax required in the new dsc_lite module:

dsc {'fruit_file':
  dsc_resource_name       => 'File',
  dsc_resource_module     => 'PSDesiredStateConfiguration',
  dsc_resource_properties => {
    ensure          => 'Present',
    destinationpath => 'C:\\Fruit.txt',
    type            => 'File',
    content         => 'Apple, Banana, Cherry.',
  }
}

With the new dsc module, we can copy paste the DSC resource parameter declaration into the dsc_resource_properties block as it is — with the exception of changing the equals to have rockets. Instead of hardcoding the DSC resource name and module into the type, it’s now configurable inside the declaration in dsc_resource_name and dsc_resource_module, allowing you to pick and choose which ones to use.

The dsc_lite module might well work better for you than the original dsc module, particularly if any of the following apply to you:

  • You need to use one or more DSC resources that are not vendored into Puppet's dsc module.
  • You want pluginsync to benefit from a reduced footprint.
  • You don't mind managing the installation of PowerShell modules containing DSC resources on your nodes.

Overall, dsc_lite is a module that has fewer safety checks than the dsc module, but provides more flexibility for the advanced DSC user.

Why you might want to consider sticking with the original dsc module

The dsc_lite module is in an early, unsupported state and undergoing rapid iteration. Switching to the new approach will require work to update the resource declarations in your manifests. In addition, with dsc_lite you're responsible for installing DSC resources onto all the nodes you want to configure with it.

We suggest sticking with the original dsc module if any of the following applies to you:

  • You have a good workflow for building an internal release of the Puppet dsc module with custom resources.
  • You want earlier feedback about the validity of manifest code.
  • You are using Microsoft-provided DSC resources, and not a custom, community-maintained, or class-based DSC resources.
  • You need the granularity of reporting in the Puppet Enterprise console which is based on each resource type being different, allowing you to filter and group on DSC resources.

This table summarizes the key benefits each of the DSC modules offers:

  `dsc` `dsc_lite`
Supported by Puppet Yes No
Ability to add custom DSC resources Yes — requires build steps Yes
DSC resources available Those bundled with the Puppet dsc module Any compatible with Invoke-DscResource
Ability to independently deploy DSC resources No Yes
Ability to read class-based DSC resources No Yes
Similar syntax to DSC No Yes
pluginsync Larger footprint Reduced footprint
Ability to report in Puppet Enterprise Yes No
Early feedback Yes No

Whether you migrate to the new dsc_lite module, or choose to stick with the supported dsc module, we hope you find the right approach for your needs. Download the dsc_lite module and give it a try. As always, let us know what you think, on Slack or by filling a ticket in JIRA.

The Puppet Windows team is continually improving the experience for Windows sysadmins on the Forge. Check back for new releases and updates on our popular modules. Subscribe to modules to get notifications.

Claire Cadman is an associate technical writer at Puppet.

Learn more

Share via:
Posted in:

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.