我需要在 ubuntu 12.04 服务器上安装 puppet 3.2.0 或更高版本以及 ruby 2.0.0-p247。
没有ruby 1.8就没有办法安装puppet吗?
我的大部分经验来自 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
最新版puppet在apt中列出
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
红宝石版本
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
我能够使用 rvm 安装 ruby 2.0 和 puppet 3.3.0
安装人偶
apt-get 安装木偶
安装 rvm
\curl -L https://get.rvm.io | 重击
注销并重新登录
安装红宝石 2.0
rvm 安装红宝石 2.0.0-p247
切换到红宝石 2.0
rvm 使用 2.0.0-p247
检查输出
$ apt-cache depends puppet
;您也许可以使用ruby-1.9
,但至少截至 2013-09-17,ruby 2.0 尚未打包在 Ubuntu 中。打包版本需要 ruby 1.8 或 1.9。您可以使用一种不推荐的方法来安装它(gem、tarball),例如
sudo gem install puppet
.