Forge Home

dsc

PowerShell Desired State Configuration (DSC)

12,886 downloads

12,648 latest version

2.4 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.1.1 (latest)
  • 0.1.0
released Sep 19th 2014
This version is compatible with:
  • Puppet Enterprise 3.x
  • Puppet 3.x

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'msutter-dsc', '0.1.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add msutter-dsc
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install msutter-dsc --version 0.1.1

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

msutter/dsc — version 0.1.1 Sep 19th 2014

Puppet Powershell DSC Module

Overview

Puppet module for managing Windows poweshell DSC resources.

This module generates Puppet Types based on DSC resources MOF schema files.

In this version, the following DSC Resources are already build and ready for usage:

Note that I use a fixed version of the Resource Kit 6 to avoid parsing issues.

This module is available on the Puppet Forge

Windows systems prerequisites

Installation on your puppet master

puppet module install msutter-dsc

Usage

You can use DSC resource by prefixing resource names and parameters with 'dsc_'. The resulting resource name has to be in lowercase. e.g: 'dsc_windowsfeature'.

Example

The following example class will install the 'Backery' website.

It's a real example and should also work for you.

class fourthcoffee(
  $websitename        = 'FourthCoffee',
  $zipname            = 'FourthCoffeeWebSiteContent.zip',
  $sourcerepo         = 'https://github.com/msutter/fourthcoffee/raw/master',
  $destinationpath    = 'C:\inetpub\FourthCoffee',
  $defaultwebsitepath = 'C:\inetpub\wwwroot',
  $zippath            = 'C:\tmp'
){

  $zipuri  = "${sourcerepo}/${zipname}"
  $zipfile = "${zippath}\\${zipname}"

  # Install the IIS role
  dsc_windowsfeature {'IIS':
    dsc_ensure => 'present',
    dsc_name   => 'Web-Server',
  } ->

  # Install the ASP .NET 4.5 role
  dsc_windowsfeature {'AspNet45':
    dsc_ensure => 'present',
    dsc_name   => 'Web-Asp-Net45',
  } ->

  # Stop an existing website (set up in Sample_xWebsite_Default)
  dsc_xwebsite {'Stop DefaultSite':
    dsc_ensure       => 'present',
    dsc_name         => 'Default Web Site',
    dsc_state        => 'Stopped',
    dsc_physicalpath => $defaultwebsitepath,
  } ->

  # Create tmp folder
  dsc_file {'tmp folder':
    dsc_ensure          => 'present',
    dsc_type            => 'Directory',
    dsc_destinationpath => $zippath,
  } ->

  # Download the site content
  dsc_xremotefile {'Download WebContent Zip':
    dsc_destinationpath => $zipfile,
    dsc_uri             => $zipuri,
  } ->

  # Extract the website content 
  dsc_archive {'Unzip and Copy the WebContent':
    dsc_ensure      => 'present',
    dsc_path        => $zipfile,
    dsc_destination => $destinationpath,
  } ->

  # Create a new Website
  dsc_xwebsite {'BackeryWebSite':
    dsc_ensure       => 'present',
    dsc_name         => $websitename,
    dsc_state        => 'Started',
    dsc_physicalpath => $destinationpath,
  }
}

As you can see, you can mix and match dsc resources with common puppet resources. All puppet metaparameters should also be supported.

Limitations

  • DSC Composite resources not yet fully supported.
  • PS Objects like 'PSCredential' as parameters value not yet supported.

Notes

The puppet types are build from the source code of the DSC Resources MOF schema files. If you want the build Puppet types for your own custom DSC Resources, read the README_BUILD

License

Copyright (c) 2014 Marc Sutter. License: Apache License, Version 2.0