How can I use xChrome DSC with Puppet?

asked 2019-01-13 10:54:49 -0600

NateSticco gravatar image

Hello, I am trying to implement the xChrome Powershell DSC Resource (https://github.com/PowerShell/xChrome) with Puppet. It appears that the xChrome resource is not supported by the puppetlabs/dsc module. So, I've been trying to figure out how to use it with puppetlabs/dsc_lite. This is my profile at this point:

class profile::win_chrome {
  include profile::win_psremoting
  pspackageprovider {'Nuget':
    ensure   => 'present',
    provider => 'windowspowershell',
  }
  psrepository { 'PSGallery':
    ensure              => present,
    source_location     => 'https://www.powershellgallery.com/api/v2/',
    installation_policy => 'trusted',
  }
  package { 'xChrome':
    ensure   => latest,
    source   => 'PSGallery',
    provider => 'windowspowershell',
  }
  dsc { 'chrome':
    require       => Package['xChrome'],
    resource_name => 'MSFT_xChrome',
    module        => 'xChrome',
    properties    => {
      ensure    => 'present',
      language  => 'en',
      localpath => 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
    }
  }
}

If I run this profile without the "dsc" section, everything appears to go as planned. I end up with the xChrome module available in Powershell. I can verify this with the commands:

Get-DSCResource -Module xChrome
Get-Module -ListAvailable -Name xChrome

However, running puppet agent against the complete code I have so far gives me the error:

Error: /Stage[main]/Profile::win_chrome/Dsc[chrome]: Count not evaluate: Failed to serialize properties into CimInstance.

The dsc_lite documentation (https://forge.puppet.com/puppetlabs/d...) mentions:

"The properties parameter recognizes any key with a hash value that contains two keys: dsc_type and dsc_properties, as a indication of how to format the data supplied. The dsc_type contains the CimInstance name to use, and the dsc_properties contains a hash or an array of hashes, representing the data for the CimInstances."

It seems like this may be the path to the solution, but I am not sure how to find out what values to use here. If anyone has any experience with this and can point me in the right direction, it would be greatly appreciated!

edit retag flag offensive close merge delete