Unable to get the ruby-ldap gem working with Puppet 4.x

692 views
Skip to first unread message

Omen Wild

unread,
Jul 16, 2015, 10:09:10 PM7/16/15
to puppet...@googlegroups.com
I have a fresh install of Puppet 4.2 on an Ubuntu 14.04 box:
root@puppet:~# /opt/puppetlabs/bin/puppetserver -v
puppetserver version: 2.1.1

We have a locally written Ruby command to do a LDAP lookup to get UIDs
for our users, but with Puppet 4.2 it errors out:

----- Begin error -----
root@puppet:~# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Internal Server Error: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- ldap
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
----- End error -----

I installed the gem with:

----- Begin quote -----
root@puppet:/etc/puppetlabs/code# /opt/puppetlabs/puppet/bin/gem install ruby-ldap
root@puppet:/etc/puppetlabs/code# /opt/puppetlabs/puppet/bin/gem list ruby-ldap

*** LOCAL GEMS ***

ruby-ldap (0.9.17)
----- End quote -----

The full back-trace is attached.

The same Ruby file works with Puppet 3.8.1 on Ubuntu 12.04 with the
ruby-ldap package installed (not as a gem).

What am I missing?

Thanks,
Omen

--
Omen Wild
Systems Administrator
Metro Cluster
traceback.txt

Matthaus Owens

unread,
Jul 17, 2015, 12:55:14 PM7/17/15
to Puppet Users
Omen,

It looks like you've installed the gem into the agent's gem path
instead of the server's. Puppetserver's docs[1] have details on how to
install a gem for puppetserver.
However, ruby-ldap is a compiled gem that won't work with jruby, so
jruby-ldap is the gem you'd want to use on the server. But, jruby-ldap
has a few issues[2], so even then it might not work. The bug I've
linked is about the LDAP terminus, so if you're writing a custom
function using ldap, it may work. jruby-ldap should have the same
interface as ruby-ldap, so it should just drop in and work.

If jruby-ldap doesn't work for you, there is a pure ruby ldap library
called ruby-net-ldap[3]. It looks like it has a different interface
than ruby-ldap, so it would probably require some rewriting of your
function.

[1] - https://docs.puppetlabs.com/puppetserver/2.1/gems.html#installing-and-removing-gems
[2] - https://tickets.puppetlabs.com/browse/SERVER-711
[3] - https://github.com/ruby-ldap/ruby-net-ldap
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20150717011546.GB10028%40descolada.ucdavis.edu.
> For more options, visit https://groups.google.com/d/optout.



--
Matthaus Owens
Puppet Labs

PuppetConf 2015 is coming to Portland, Oregon! Join us October 5-9.
Register now to take advantage of the Early Bird discount —save $249!

Omen Wild

unread,
Jul 17, 2015, 2:06:56 PM7/17/15
to puppet...@googlegroups.com
Quoting Matthaus Owens <matt...@puppetlabs.com> on Fri, Jul 17 09:55:
>
> It looks like you've installed the gem into the agent's gem path
> instead of the server's. Puppetserver's docs[1] have details on how to
> install a gem for puppetserver.

So obvious when you point it out. Following the fine documentation fixed
it. jruby-ldap "appears" to be working, though I have a bunch more code
cleanup to make our code compatible with Puppet 4. Thanks for the info on
the pure ruby ldap library. Our LDAP code is pretty simple so switching
should be pretty easy if it turns out to be necessary.

Thanks, really appreciate the help.
Reply all
Reply to author
Forward
0 new messages