Ask Your Question
0

Using gem from new puppetserver custom function?

asked 2014-10-15 13:45:27 -0500

dbschofield gravatar image

I am testing out the new puppetserver and finding a problem with referencing a gem installed to the local ruby.

A custom function is installed to /usr/lib/ruby/site_ruby/1.8/pupppet/parser/functions/myfunction.rb. It makes use of the mysql2 gem

module Puppet::Parser::Functions
  newfunction(:myfunction, :type => :rvalue) do |args|
    require 'mysql2'
    ...
end

The mysql2 gem is installed to /usr/lib/ruby/gems/1.8/gems/mysql2-0.3.16/lib/mysql2.rb.

When doing a puppet run on a managed node we get the following error.

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: no such file to load -- mysql2

My question is: How make a gem visible to the new puppetserver so it can be used by a custom function?

I should note this set up works fine when running puppetmaster 3.7 instead of the new puppetserver.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-10-15 14:27:03 -0500

cprice404 gravatar image

We have some documentation on this topic in the github repo:

https://github.com/puppetlabs/puppet-...

This info should be published to our main docs site before too long, but for now it's just in the git repo.

The short answer is: we use an embedded JRuby interpreter to run ruby code in Puppet Server, and we have a separate location where you can install and manage gems for Puppet Server. It doesn't look in your system ruby path.

Also, note that for some gems that require native (C) extensions, you may have to make some small changes to switch them over to a JRuby-compatible version (e.g., jruby-mysql instead of mysql). There are links in the documentation above that provide more info.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-10-15 13:45:27 -0500

Seen: 404 times

Last updated: Oct 15 '14