2015年11月12日木曜日

[CentOS6] yum と gem で serverspec をインストールする


CentOS6.7 に yum と gem で serverspec をインストールします。

まず、 yum で ruby と rubygems をいれます。
[root@localhost ~]# yum install ruby rubygems

つぎに、gem で serverspec をいれようとすると以下のようにエラーになりました。
[root@localhost ~]# gem install serverspec
ERROR:  Error installing serverspec:
       net-ssh requires Ruby version >= 2.0.


最新の net-ssh は、ruby2.0 以上が必要みたいですが、CentOS6.7 の ruby は 1.8.7 です。
[root@localhost ~]# ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]

インストール可能な net-ssh のバージョンを確認すると以下のとおり。
[root@localhost ~]# gem list net-ssh -ar

*** REMOTE GEMS ***

net-ssh (3.0.1, 2.9.2, 2.9.1, 2.9.0, 2.8.0, 2.7.0, 2.6.8, 2.6.7, 2.6.6, 2.6.5, 2.6.4, 2.6.3, 2.6.2, 2.6.1, 2.6.0, 2.5.2, 2.5.1, 2.5.0, 2.4.0, 2.3.0, 2.2.2, 2.2.1, 2.2.0, 2.1.4, 2.1.3, 2.1.0, 2.0.24, 2.0.23, 2.0.22, 2.0.21, 2.0.20, 2.0.19, 2.0.18, 2.0.17, 2.0.16, 2.0.15, 2.0.14, 2.0.13, 2.0.11, 2.0.10, 2.0.9, 2.0.8, 2.0.7, 2.0.6, 2.0.5, 2.0.4, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 1.1.4, 1.1.3, 1.1.2, 1.1.1, 1.1.0, 1.0.10, 1.0.9, 1.0.8, 1.0.7, 1.0.6, 1.0.5, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0, 0.9.0, 0.6.0, 0.5.0)
net-ssh-askpass (0.0.3)
net-ssh-gateway (1.2.0, 1.1.0, 1.0.1, 1.0.0)
net-ssh-kerberos (0.2.7, 0.2.6, 0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2.0, 0.1.3, 0.1.2, 0.1.0)
net-ssh-krb (0.4.0, 0.3.0)
net-ssh-multi (1.2.1, 1.2.0, 1.1, 1.0.1, 1.0.0)
net-ssh-net-ssh (2.0.14, 2.0.13, 2.0.12)
net-ssh-ng (2.10.2.1, 2.10.2, 2.10.1, 2.10.0, 2.9.1)
net-ssh-open3 (0.1.6, 0.1.5, 0.1.4, 0.1.3, 0.1.2)
net-ssh-plus (0.0.2, 0.0.1)
net-ssh-session (0.1.6, 0.1.5, 0.1.4, 0.1.3, 0.1.2, 0.1.1, 0.1.0)
net-ssh-shell (0.2.0, 0.1.0)
net-ssh-simple (1.6.12, 1.6.11, 1.6.10, 1.6.9, 1.6.8, 1.6.7, 1.6.6, 1.6.5, 1.6.4, 1.6.3, 1.6.2, 1.6.1, 1.6.0, 1.5.9, 1.5.8, 1.5.4, 1.5.3, 1.5.2, 1.5.1, 1.5.0, 1.4.5, 1.4.1, 1.4.0, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0, 1.1.1, 1.1.0, 1.0.1, 1.0.0, 0.9.0)
net-ssh-socks (0.0.2, 0.0.1)
net-ssh-telnet (0.0.2, 0.0.1)

とりあえず、先に net-ssh だけ、古いバージョン(2.9.2)を入れます。
[root@localhost ~]# gem install net-ssh --version "=2.9.2"
Successfully installed net-ssh-2.9.2
1 gem installed
Installing ri documentation for net-ssh-2.9.2...
Installing RDoc documentation for net-ssh-2.9.2...

これで、serverspec が入ります
[root@localhost ~]# gem install serverspec
Successfully installed net-scp-1.2.1
Successfully installed net-telnet-0.1.1
Successfully installed sfl-2.2
Successfully installed specinfra-2.44.1
Successfully installed serverspec-2.24.2
5 gems installed
Installing ri documentation for net-scp-1.2.1...
Installing ri documentation for net-telnet-0.1.1...
Installing ri documentation for sfl-2.2...
Installing ri documentation for specinfra-2.44.1...
Installing ri documentation for serverspec-2.24.2...
Installing RDoc documentation for net-scp-1.2.1...
Installing RDoc documentation for net-telnet-0.1.1...
Installing RDoc documentation for sfl-2.2...
Installing RDoc documentation for specinfra-2.44.1...
Installing RDoc documentation for serverspec-2.24.2...

最後に rake をいれます。
[root@localhost ~]# gem install rake
Successfully installed rake-10.4.2
1 gem installed
Installing ri documentation for rake-10.4.2...
Installing RDoc documentation for rake-10.4.2...