Using gem from new puppetserver custom function?

148 views
Skip to first unread message

Schofield

unread,
Oct 15, 2014, 2:50:55 PM10/15/14
to puppet...@googlegroups.com
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.

Kylo Ginsberg

unread,
Oct 15, 2014, 3:00:08 PM10/15/14
to puppet...@googlegroups.com
On Wed, Oct 15, 2014 at 11:50 AM, Schofield <dbsch...@gmail.com> wrote:
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?


Best,
Kylo
--
Kylo Ginsberg | ky...@puppetlabs.com | irc: kylo | twitter: @kylog

Schofield

unread,
Oct 15, 2014, 5:40:45 PM10/15/14
to puppet...@googlegroups.com
Thanks for the reply.  That does indeed look to be the solution. 

Corey Osman

unread,
Oct 15, 2014, 5:50:56 PM10/15/14
to puppet...@googlegroups.com
Piggybacking off the same topic.


I have a few parsers that use the JSON gem so require 'json' is at the top of my parser which requires the native C extensions.  Does the new puppet server come with a jrbuy version of the json gem that contains the functions?  How would I write a parser that can be used on the ruby puppet master and the new jruby puppet server if the gems are slightly different and have different method names?  

Kevin Corcoran

unread,
Oct 17, 2014, 2:37:43 PM10/17/14
to puppet...@googlegroups.com
I just spent a little time looking into this, and the json gem appears to work just fine under JRuby.  It looks like there *used* to be a gem called json-jruby that could be used instead, but it appears that it has now been merged into json - so, long story short, 'json' should work just fine.
Reply all
Reply to author
Forward
0 new messages