Puppet fails to install Rubygem that installs fine normally

puppetrubygems

I'm using the following to try and install a Rubygem with Puppet.

package { 'reaper':
  ensure           => 'installed',
  provider         => 'gem',
  source           => 'http://192.168.1.101:9292/',
  install_options  => ['--no-ri', '--no-rdoc']
}

When I run puppet agent --test I get the following error.

Error: Execution of '/usr/bin/gem install --source http://192.168.1.101:9292/ reaper' returned 1: ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::RemoteFetcher::OpenSSL

Error: /Package[reaper]/ensure: change from absent to present failed: Execution of '/usr/bin/gem install --source http://192.168.1.101:9292/ reaper' returned 1: ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::RemoteFetcher::OpenSSL

However, when I run gem install --source http://192.168.1.101:9292/ reaper as root from the command line the gem installs just fine.

Anyone have an idea of what's going on? Does the Puppet agent get executed with some different environment variables that could be causing this error?

===== EDIT =====

Here's some additional information about the environment:

#output from `grep libssl /proc/{irb pid}/maps`
b70e0000-b7131000 r-xp 00000000 08:01 393357     /lib/i386-linux-gnu/libssl.so.1.0.0
b7131000-b7133000 r--p 00050000 08:01 393357     /lib/i386-linux-gnu/libssl.so.1.0.0
b7133000-b7137000 rw-p 00052000 08:01 393357     /lib/i386-linux-gnu/libssl.so.1.0.0

Ruby and RubyGems (installed via aptitude install rubygems):

# ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

# gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.15
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
  - INSTALLATION DIRECTORY: /var/lib/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby1.8
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /var/lib/gems/1.8
     - /root/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

SSL (installed automatically):

# aptitude search ~i | grep ssl
i A libssl-dev                      - SSL development libraries, header files an
i A libssl-doc                      - SSL development documentation documentatio
i   libssl1.0.0                     - SSL shared libraries                      
i A openssl                         - Secure Socket Layer (SSL) binary and relat

# aptitude show libssl1.0.0
Package: libssl1.0.0                     
State: installed
Automatically installed: no
Multi-Arch: same
Version: 1.0.1-4ubuntu5.9
Priority: required
Section: libs
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: i386
Uncompressed Size: 2,748 k
Depends: libc6 (>= 2.7), zlib1g (>= 1:1.1.4), debconf (>= 0.5) | debconf-2.0
PreDepends: multiarch-support
Breaks: openssh-client (< 1:5.9p1-4), openssh-server (< 1:5.9p1-4)
Description: SSL shared libraries

===== EDIT #2 =====

I'm wondering why I'm even encountering an OpenSSL error… the source I'm using is http, not https. Thoughts?!

Best Answer

I've run into similar issues before, and I'm about 99% sure your Ruby runtime is trying to load a version of OpenSSL other than the one it was built against, most likely due to the presence of a custom libssl in /usr/local. Can you do the following:

  1. Start an irb session with the Ruby runtime used to run Puppet, then require 'openssl' and leave the session running
  2. In another terminal, run grep libssl /proc/$(pidof irb)/maps and copy the output
  3. Update your post with the output you captured above

Other information on what version of Ruby/OpenSSL you're running and how they were installed would also be tremendously helpful in diagnosing this issue.

Related Topic