Serverspec (2/3) ：スタンドアロン環境へのServerspecインストール

スタンドアロン環境へServerspecへインストールしてみる。

## 資材のダウンロード

* Rubyのダウンロード
RHEL同梱版ではServerspecのインストールでwarningが出るため最新版を導入する。
以下からダウンロード、/tmpに格納
**Ruby 2.1.1**
https://www.ruby-lang.org/ja/<br>
<br>

* RubyGemsのダウンロード
以下からダウンロード、/tmpに格納
**RubyGems v2.2.2**
http://rubygems.org/pages/download<br>
<br>

* Serverspecのダウンロード
必要パッケージをダウンロード、/tmp/serverspecに格納。
**serverspec 1.0.0**
http://rubygems.org/gems/serverspec
**specinfra 1.0.1**
http://rubygems.org/gems/specinfra
**highline 1.6.21**
http://rubygems.org/gems/highline
**rspec 2.14.1**
http://rubygems.org/gems/rspec
**net-ssh 2.8.0**
http://rubygems.org/gems/net-ssh
**rspec-mocks 2.14.6**
http://rubygems.org/gems/rspec-mocks
**rspec-expectations 2.14.5**
http://rubygems.org/gems/rspec-expectations
**rspec-core 2.14.8**
http://rubygems.org/gems/rspec-core
**diff-lcs 1.2.5**
http://rubygems.org/gems/diff-lcs<br>
<br>

## Serverspecのインストール
Serverspecのインストール要件であるRubyとRubyGemsをインストールする。
1.Rubyのインストール

```text:
# cd /tmp
# tar zxvf ruby-2.1.1.tar.gz
# cd ruby-2.1.1
# ./configure 
# make
# make install
```
<br>

2.RubyGemsのインストール

```text:
# cd /tmp
# tar zxvf rubygems-2.2.2.tgz 
# cd rubygems-2.2.2
# ruby setup.rb 
```
<br>

3.Serverspecのインストール

```text:
# cd /tmp/serverspec
# gem install serverspec --local
```

<br><br>
もし以下のエラーが出た場合は追加手順が必要。<br>

```text:
# gem install serverspec --local
ERROR:  Loading command: install (LoadError)
	cannot load such file -- zlib
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass
```

zlibをインストールしただけでは解決できなかったが、以下のコマンドで補えるらしい。<br>

```text:
# cd /tmp/ruby-2.1.1/ext/zlib
# ruby extconf.rb
# make
# make install
```
コマンド実行後、再度Serverspecのインストールを行う。<br>
<br>

お疲れ様でした。

<br>
参考：Serverspecインストール時のエラーログ

```text:
[root@nhss01 serverspec]# gem install serverspec --local
Successfully installed net-ssh-2.8.0
Successfully installed rspec-core-2.14.8
Successfully installed diff-lcs-1.2.5
Successfully installed rspec-expectations-2.14.5
Successfully installed rspec-mocks-2.14.6
Successfully installed rspec-2.14.1
Successfully installed highline-1.6.21
Successfully installed specinfra-1.0.1
Successfully installed serverspec-1.0.0
Installing ri documentation for diff-lcs-1.2.5
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Installing ri documentation for highline-1.6.21
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Installing ri documentation for net-ssh-2.8.0
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Installing ri documentation for rspec-2.14.1
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Installing ri documentation for rspec-core-2.14.8
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Installing ri documentation for rspec-expectations-2.14.5
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Installing ri documentation for rspec-mocks-2.14.6
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Installing ri documentation for serverspec-1.0.0
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Installing ri documentation for specinfra-1.0.1
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Done installing documentation for diff-lcs, highline, net-ssh, rspec, rspec-core, rspec-expectations, rspec-mocks, serverspec, specinfra after 15 seconds
9 gems installed
```
Rdocに関するエラー。Rubyが古いと出るらしい。。。