0

Hopefully this is the right place for this. i am using Puppet on Windows Server and looking to install a Powershell module found in the Powershell Gallery using Puppet. I have read through https://forge.puppet.com/puppetlabs/dsc/readme however there is nothing about ensuring a gallery module is installed on the system. I am assuming it would be through something like

dsc_module { 'module_name':
  dsc_ensure => 'present',
}

This didn't seem to work though. No error either. My guess is that I will need to use somethingn like chocolatey. can anyone confirm if this is possible?

1 Answer 1

1

You can do this with a different module:

The powershellmodule Puppet module looks like it can manage Package repositories and install modules from them, though I've not used it myself. Example from the module's description page:

pspackageprovider {'Nuget':
  ensure => 'present'
}

psrepository { 'PSGallery':
  ensure              => present,
  source_location     => 'https://www.powershellgallery.com/api/v2/',
  installation_policy => 'trusted',
}

package { 'module_name':
  ensure   => latest,
  provider => 'windowspowershell',
  source   => 'PSGallery',
}

I did have a look and I couldn't see an in-box way to install a PowerShell module using just DSC; there's not a DSC resource called 'module' which is what I think you were trying to configure using the Puppet DSC module.

EDIT:

Just checked again and there is a resource for package management. So you could update your original code as follows:

dsc_packagemanagement { 'module_name':
  dsc_ensure => 'present',
  dsc_name => 'module_name',
}

https://docs.microsoft.com/en-us/powershell/dsc/packagemanagementdscresource

4
  • Sorry for the delay on getting back to your response. I haven't been able to get either methods to work. both give an error around unknown resource type. it doesn't like dsc_packagemanagement or dsc_PackageManagement. I also got the error in the first bit with pspackageprovider
    – Laywah
    Aug 7, 2018 at 5:40
  • after looking into this further. Your first answer has worked. I had to import an extra module which I found out that I didn't have. The only thing I have adjusted however was installation_policy => 'untrusted',. I have tested this and it still seems to work fine. I just feel a little better from a security point of view not trusting the repo.
    – Laywah
    Aug 7, 2018 at 8:10
  • Although there is an MS DSC "PackageManagement" resource and Puppet Labs have "converted" almost all MS resources, for some reason, they haven't included this one (yet), so dsc_packagemanagement {...} won't work. The "converted" list of "resources" to "types" can be found: github.com/puppetlabs/puppetlabs-dsc/tree/master/lib/puppet/…
    – woter324
    May 30, 2019 at 20:14
  • The hbuckle module hasn't been updated in 2 years and doesn't work because of the shift sites not supporting TLS <1.2 and Windows Powershell's lack of support for TLS 1.2 out of the box. There is a forked version from encore that includes the TLS fix. Jul 10, 2020 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .