Powershell DSC Resource Modules

This document is a request for suggestions on DSC module resource for PowerShell cookbook provided by chef.

Quick overview of DSC resource module

Configuration MyWebConfig
{
   # A Configuration block can have zero or more Node blocks
   Node "Server001"
   {
      # Next, specify one or more resource blocks
      # File is a built-in resource you can use to manage files and directories
      # This example ensures files from the source directory are present
      File MyFileExample
      {
         # You can also set Ensure to "Absent"
         Ensure = "Present"
         # Default is “File”
         Type = "Directory"
         Recurse = $true
         SourcePath = $WebsiteFilePath
         DestinationPath = "C:\inetpub\wwwroot"
      }
   }
}
$env: psmodulepath (folder)
  |- <ModuleName> (folder)
    |-  <ModuleName.psd1> (file,required)
    |- DSCResources (folder)
      |- <DSCResourceName1> (folder)
        |- <DSCResourceName1.psd1> (file, optional)
        |- <DSCResourceName1.psm1> (file, required)
        |- <DSCResourceName1.schema.mof> (file, required)
      |- <DSCResourceName2>(folder)
        |- <DSCResourceName2.psd1> (file, optional)
        |- <DSCResourceName2.psm1> (file, required)
        |- <DSCResourceName2.schema.mof> (file, required)

Goal

The goal of the changes mentioned in this document is to manage custom DSC resource modules for desired workstation. This change is required for user to easily allow access for custom DSC resources. Currently there is no automated way to manage custom resources. We are adding DSC module resource to PowerShell cookbook to manage (i.e install/uninstall) custom resource.

Requirements

The resource have meaningful name, powershell_dsc_module.

Actions

:install (default)

It will install DSC module. User can use this module in configuration block by using 'Import-DscResource'.

:uninstall

It will remove DSC module by deleting DSC resource module dir from $psmodulepath location.

Attributes

Example

powershell_dsc_module "test_module" do
  module_name "test_module"
  remote_url "https://s3.aws.com/test_module.zip"
  action :install
end

powershell_dsc_module "test_module" do
  module_name "test_module"
  action :uninstall
end

Copyright

This work is in the public domain. In jurisdictions that do not allow for this, this work is available under CC0. To the extent possible under law, the person who associated CC0 with this work has waived all copyright and related or neighboring rights to this work.