我正在使用以下方法来尝试使用Puppet安装Rubygem。
package { 'reaper': ensure => 'installed', provider => 'gem', source => 'http://192.168.1.101:9292/', install_options => ['--no-ri', '--no-rdoc'] }
当我运行puppet agent --test我得到以下错误。
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
但是,当我从命令行运行gem install --source http://192.168.1.101:9292/ reaper ,gem安装就好了。
任何人都知道发生了什么? 傀儡代理是否会执行一些可能导致此错误的不同环境variables?
=====编辑=====
以下是有关环境的其他信息:
#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和RubyGems(通过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(自动安装):
# 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 <[email protected]> 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
=====编辑#2 =====
我想知道为什么我什至遇到一个OpenSSL错误…我使用的源是http ,而不是https 。 思考?
我之前遇到过类似的问题,我大概99%的人确定你的Ruby运行时正试图加载一个OpenSSL以外的版本,这很可能是由于在/usr/local存在一个自定义的libssl /usr/local 。 你能做到以下几点:
irb会话,然后require 'openssl'并让会话继续运行 grep libssl /proc/$(pidof irb)/maps并复制输出 关于您正在运行的Ruby / OpenSSL版本以及安装方式的其他信息对于诊断此问题也非常有帮助。
好吧,所以我觉得我知道这个交易是什么…
看起来好像我正在获取uninitialized constant Gem::RemoteFetcher::OpenSSL错误不是因为SSL问题,而是因为找不到源服务器。 我的印象是--source选项正在被使用,但我不认为它是(见下文)。
作为Puppet客户端的根目录,我将gem源位置更改为我的自定义gem服务器。 以root身份运行gem env证实了这一变化。 然后,我更新了我的Puppet清单,以便在Puppet代理运行时输出gem env的结果,并且在由Puppet代理执行gem命令时,源仍然是http://rubygems.org/ 。 经过进一步检查,我得到的印象是, HOME环境variables正在被更改为/正在执行gem命令(主要是因为/.gem/ruby/1.8被列为GEM PATH,当gem env被Puppet代理执行而不是/root/.gem/ruby/1.8或/var/lib/puppet/.gem/ruby/1.8 )。
为了testing,我复制了我的/root/.gemrc文件(它指定了我的自定义gem源文件)到/.gemrc并再次运行了Puppet代理。 这一次,没有发生错误,我想要的gem已成功安装。 Puppet的主目录/etc/passwd被设置为/var/lib/puppet ,因此必须将Puppet代理configuration为将其主目录指向执行清单之前/之前。