Search code examples
puppet

autoload error when using puppetlabs/chocolatey module


I am not new to puppet, but I am new to using it on Windows. Trying to configure chocolatey using the puppetlabs/chocolatey module. Initial puppet run without the module worked just fine. Then I added include chocolatey to the manifest, and it downloaded and installed chocolatey. So far, so good. However, then I went to add a custom source like so:

chocolateysource { 'mysource':
  ensure   => present,
  location => 'https://my.chocolatey.source',
  priority => 10,
}

Now I get the following message when running puppet agent -t:

PS C:\Windows\system32> puppet agent -t
Error: Could not autoload puppet/provider/package/chocolatey: C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/package/chocolatey.rb:280: syntax error, unexpected '.'
      pin_output&.split("\n")&.each { |pin| pin...
                  ^
C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/package/chocolatey.rb:280: syntax error, unexpected '.'
...      pin_output&.split("\n")&.each { |pin| pins << pin.spli...
...                               ^
Error: Facter: error while resolving custom facts in C:/ProgramData\PuppetLabs\puppet\cache\lib\facter\package_provider.rb: Could not autoload puppet/provider/package/chocolatey: C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/package/chocolatey.rb:280: syntax error, unexpected '.'
      pin_output&.split("\n")&.each { |pin| pin...
                  ^
C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/package/chocolatey.rb:280: syntax error, unexpected '.'
...      pin_output&.split("\n")&.each { |pin| pins << pin.spli...
...                               ^
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Redefining package in Puppet::Type
Error: Could not autoload puppet/type/chocolateysource: C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/type/chocolateysource.rb:221: syntax error, unexpected '.'
    parameter(:password)&.sensitive = true
                          ^
Error: Could not retrieve catalog from remote server: Could not intern from text/pson: Could not autoload puppet/type/chocolateysource: C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/type/chocolateysource.rb:221: syntax error, unexpected '.'
    parameter(:password)&.sensitive = true
                          ^
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

As a non-Windows user, I feel like I'm missing something to make this work, but I'm not sure what it is. I have verified that .Net framework is installed, but not sure what else to check here. Thanks in advance for any help.


Solution

  • Turns out the version was the issue. I had mistakenly installed puppet 4 agent, while the server is puppet 7.