3

I'm using a third-party module that uses a feature of Ruby that wasn't introduced until version 2.1. The ruby version in my runtime environment is 2.1.9:

Debug: Facter: fact "ruby" has resolved to { platform => "x86_64-linux", sitedir => "/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0", version => "2.1.9" }. 

so in theory I should be fine. However, when I run the puppet agent I get

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, undefined method `to_h' for #<Array:0xc8fd201> 

Array#to_h is available on Ruby 2.1.9, so this error implies the custom function in the module is being evaluated with a version of Ruby prior to 2.1, though I can't find any other Ruby version it could be using. I've completely scrubbed the environment of anything before version 2.4, which leaves only Puppet's in-built 2.1.9 version.

What is going on here?

1 Answer 1

2

What's going on is that while your puppet agent has the right ruby version as you've found, the actual compilation of the catalog happens in the puppet master service.

There's your culprit in this case; the master doesn't use normal ruby, it uses JRuby. Even in the absolute latest puppetserver versions as of this writing (5.1.4), the default JRuby in use by puppetserver is 1.7. To switch to JRuby 9k and get the functions you're expecting (be aware that they're calling it "somewhat experimental"), make sure your puppet master is running 5.0 or newer, then change the environment variable as described in the docs for the newer JRuby version.

You must log in to answer this question.