我需要在 ubuntu 12.04 服务器上安装 puppet 3.2.0 或更高版本以及 ruby 2.0.0-p247。
没有办法安装 puppet 吗没有ruby 1.8?
我的大部分经验来自 CentOS,所以我可能错过了一些简单的 apt 功能。
我的设置:
确保没有红宝石
root@gitlab:~# which ruby
root@gitlab:~# ruby --version
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: apt-get install <selected package>
从官方 ppa 安装 puppet
root@gitlab:~# cat /etc/apt/sources.list.d/puppetlabs.list
deb http://apt.puppetlabs.com precise main
deb-src http://apt.puppetlabs.com precise main
deb http://apt.puppetlabs.com precise dependencies
deb-src http://apt.puppetlabs.com precise dependencies
apt 中列出了最新版本的 puppet
root@gitlab:~# apt-cache policy puppet|head
puppet:
Installed: (none)
Candidate: 3.3.0-1puppetlabs1
Version table:
3.3.0-1puppetlabs1 0
500 http://apt.puppetlabs.com/ precise/main amd64 Packages
3.2.4-1puppetlabs1 0
500 http://apt.puppetlabs.com/ precise/main amd64 Packages
3.2.3-1puppetlabs1 0
500 http://apt.puppetlabs.com/ precise/main amd64 Packages
安装 puppet 3.3.0 会自动安装 ruby 1.8。
root@gitlab:~# apt-get install puppet-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
augeas-lenses debconf-utils facter hiera libaugeas-ruby libaugeas-ruby1.8 libaugeas0 libjson-ruby libruby libruby1.8
libshadow-ruby1.8 ruby ruby-json ruby-rgen ruby1.8 virt-what
Suggested packages:
augeas-doc augeas-tools ruby-selinux libselinux-ruby1.8 librrd-ruby1.9.1 librrd-ruby1.8 ri ruby-dev ruby1.8-examples ri1.8
The following NEW packages will be installed:
augeas-lenses debconf-utils facter hiera libaugeas-ruby libaugeas-ruby1.8 libaugeas0 libjson-ruby libruby libruby1.8
libshadow-ruby1.8 puppet-common ruby ruby-json ruby-rgen ruby1.8 virt-what
0 upgraded, 17 newly installed, 0 to remove and 92 not upgraded.
Need to get 3,664 kB of archives.
After this operation, 14.1 MB of additional disk space will be used.
Do you want to continue [Y/n]?
傀儡版本
root@gitlab:/tmp/ruby-2.0.0-p247# puppet --version
3.3.0
ruby 版本
root@gitlab:/tmp/ruby-2.0.0-p247# ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
(请注意,ruby 是通过更新选项自动安装的)
root@gitlab:/tmp/ruby-2.0.0-p247# ll `which ruby`
lrwxrwxrwx 1 root root 22 Sep 18 02:57 /usr/bin/ruby -> /etc/alternatives/ruby*
root@gitlab:/tmp/ruby-2.0.0-p247# update-alternatives --list ruby
/usr/bin/ruby1.8
然后我从源代码将 ruby 2.0 安装到它自己的目录中
./configure --prefix=/usr/bin/ruby2.0
然后使用 update-alternatives 注册 ruby 2.0
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby2.0/bin/ruby 10
通过 update-alternatives 切换到 ruby 2.0
root@gitlab:/tmp/ruby-2.0.0-p247# update-alternatives --set ruby /usr/bin/ruby2.0/bin/ruby
update-alternatives: using /usr/bin/ruby2.0/bin/ruby to provide /usr/bin/ruby (ruby) in manual mode.
root@gitlab:/tmp/ruby-2.0.0-p247# ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
我已经这样做过几次了,只要which ruby
指向除 1.8 之外的任何 ruby 版本,puppet 都会返回以下错误:
root@gitlab:/tmp/ruby-2.0.0-p247# puppet --version
/usr/bin/ruby2.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- puppet/util/command_line (LoadError)
from /usr/bin/ruby2.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /usr/bin/puppet:3:in `<main>'
我怎样才能使用 ruby 2.0 安装 puppet?
Puppet 3.3 与 ruby 2.0 兼容,因为它已在puppet 的网站
其他资源
http://projects.puppetlabs.com/issues/18494
RVM 似乎比我需要的复杂得多。此外,常见问题解答说不要将它与 sudo 一起使用,或者以 root 身份运行它,而我必须这样做。
https://rvm.io/
http://rvm.io/support/faq
https://stackoverflow.com/questions/1892877/how-do-i-make-ruby-1-9-the-default-ruby-on-ubuntu
答案1
我能够使用 rvm 安装 ruby 2.0 和 puppet 3.3.0
安装 puppet
apt-get 安装 puppet
安装 rvm
\curl -Lhttps://get.rvm.io| 重击
注销并重新登录
安装 ruby 2.0
rvm 安装 ruby 2.0.0-p247
切换到 ruby 2.0
rvm 使用 2.0.0-p247
答案2
检查 的输出$ apt-cache depends puppet
;您可能能够使用ruby-1.9
,但至少截至 2013-09-17,ruby 2.0 尚未在 Ubuntu 中打包。
答案3
打包版本需要 ruby 1.8 或 1.9。您可以使用不推荐的方法之一来安装它(gem,tarball),例如sudo gem install puppet
。