rbenvを使ってrubyとserverspecをインストール

serverspecというrubyでできている基盤テストツールを試したくなったのでとりあえずCentOS7にrubyをインストールしました。
その時のメモです。

まずはyumで必要なものを一式インストール。すでにインストール済みのものがあれば外してください。


yum -y install git
yum install -y openssl-devel readline-devel zlib-devel
yum -y groupinstall "Development Tools"

rbenvとruby-buildのインストール。


git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
mkdir -p ~/.rbenv/plugins
source ~/.bash_profile
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build


最後に最新版のrubyをインストールしてbundlerとserverspecをインストール。


rbenv install 2.5.1
rbenv rehash
rbenv global 2.5.1
ruby -v

rbenv exec gem install bundler
rbenv rehash

bundle init
vi Gemfile
gem "serverspec"
gem "winrm" #windows

bundle
rbenv rehash

rbenvやruby-buildは公式サイトにある手順をほとんどそのまま実施すれば問題ないと思います。

serverspecは多分これで動くはず。


mkdir any_directory
cd any_directory
serverspec-init

ここまではうまくいきました。そのうち動作検証結果もUPしたいと思います。