itamae 生活 4日目
itamae 生活4日目
前回 謎エラーの暫定対処ができたので、本線に戻る。
Today's Goal
- rbenv で ruby を入れる
bundler 環境に切り替える
ここまで itamae はグローバルな gem に入れていたが、 rbenv は plugin で入れようを思うので、この際 bundler 環境に移行する。
itamae init
で Gemfile も併せて作られているので、そちらに前回のエラー暫定対処を踏まえて thor のバージョンを v 0.19.1 を上限に指定する。
source 'https://rubygems.org' gem 'itamae' gem 'itamae-plugin-recipe-rbenv' gem 'thor', '<= 0.19.1'
んで、 bundle install
お好みで --path
オプションもどーぞ
rails ロール作成
今回は rails という role を作った
$ bundle exec itamae g role rails
create
create default.rb
create files/.keep
create templates/.keep
roles/rails/default.rb
まずは、 roles/rails/default.rb に以下1行だけ
include_recipe 'rbenv::system'
node.yml
どこに置くのが適切か判断つかなかったので、 roles/rails/node.yml とした
README にはオプション設定含めつらつらと書いてあるが、Ruby v2.3.3 を入れる最小は以下なのかな。
※scheme も default git
になるので削れそうではある
rbenv: global: 2.3.3 versions: - 2.3.3 scheme: https
Execution
しかしエラー...
$ bundle exec itamae ssh -h xx.xx.xx.xx -i ~/.ssh/hogepiyo.pem -u ec2-user -y roles/rails/node.yml roles/rails/default.rb INFO : Starting Itamae... INFO : Loading node data from /Users/kawakubox/Workspace/generic-recipe/roles/rails/node.yml... INFO : Recipe: /Users/kawakubox/Workspace/generic-recipe/roles/rails/default.rb INFO : Recipe: /Users/kawakubox/Workspace/generic-recipe/vendor/bundle/ruby/2.3.0/gems/itamae-plugin-recipe-rbenv-0.6.3/lib/itamae/plugin/recipe/rbenv/system.rb INFO : Recipe: /Users/kawakubox/Workspace/generic-recipe/vendor/bundle/ruby/2.3.0/gems/itamae-plugin-recipe-rbenv-0.6.3/lib/itamae/plugin/recipe/rbenv/install.rb INFO : Recipe: /Users/kawakubox/Workspace/generic-recipe/vendor/bundle/ruby/2.3.0/gems/itamae-plugin-recipe-rbenv-0.6.3/lib/itamae/plugin/recipe/rbenv/dependency.rb INFO : execute[rbenv install 2.3.3] executed will change from 'false' to 'true' ERROR : stdout | Installing ruby-2.3.3... ERROR : stdout | ERROR : stdout | [1mBUILD FAILED[m (Amazon Linux AMI 2016.09 using ruby-build 20161121-14-gd799bdd) ERROR : stdout | ERROR : stdout | Inspect or clean up the working tree at /tmp/ruby-build.20161214144733.28704 ERROR : stdout | [33mResults logged to /tmp/ruby-build.20161214144733.28704.log[m ERROR : stdout | ERROR : stdout | Last 10 log lines: ERROR : stdout | config.sub already exists ERROR : stdout | checking build system type... x86_64-pc-linux-gnu ERROR : stdout | checking host system type... x86_64-pc-linux-gnu ERROR : stdout | checking target system type... x86_64-pc-linux-gnu ERROR : stdout | checking for gcc... no ERROR : stdout | checking for cc... no ERROR : stdout | checking for cl.exe... no ERROR : stdout | configure: error: in `/tmp/ruby-build.20161214144733.28704/ruby-2.3.3': ERROR : stdout | configure: error: no acceptable C compiler found in $PATH ERROR : stdout | See `config.log' for more details ERROR : Command ` export RBENV_ROOT=/usr/local/rbenv export PATH="/usr/local/rbenv/bin:${PATH}" eval "$(rbenv init --no-rehash -)" rbenv install 2.3.3` failed. (exit status: 1) ERROR : execute[rbenv install 2.3.3] Failed.
README をまるっとコピペしても動かなかったので、うんうん唸ってたんですが rbenv::dipendency を眺めていてハッと思いついた。
platform: redhat # <-- 追記 rbenv: global: 2.3.3 versions: - 2.3.3 scheme: https
再度実行
$ bundle exec itamae ssh -h xx.xx.xx.xx -i ~/.ssh/hogepiyo.pem -u ec2-user -y roles/rails/node.yml roles/rails/default.rb INFO : Starting Itamae... INFO : Loading node data from /Users/kawakubox/Workspace/generic-recipe/roles/rails/node.yml... INFO : Recipe: /Users/kawakubox/Workspace/generic-recipe/roles/rails/default.rb INFO : Recipe: /Users/kawakubox/Workspace/generic-recipe/vendor/bundle/ruby/2.3.0/gems/itamae-plugin-recipe-rbenv-0.6.3/lib/itamae/plugin/recipe/rbenv/system.rb INFO : Recipe: /Users/kawakubox/Workspace/generic-recipe/vendor/bundle/ruby/2.3.0/gems/itamae-plugin-recipe-rbenv-0.6.3/lib/itamae/plugin/recipe/rbenv/install.rb INFO : Recipe: /Users/kawakubox/Workspace/generic-recipe/vendor/bundle/ruby/2.3.0/gems/itamae-plugin-recipe-rbenv-0.6.3/lib/itamae/plugin/recipe/rbenv/dependency.rb INFO : package[gcc] installed will change from 'false' to 'true' INFO : package[gdbm-devel] installed will change from 'false' to 'true' INFO : package[libyaml-devel] installed will change from 'false' to 'true' INFO : execute[rbenv install 2.3.3] executed will change from 'false' to 'true' INFO : execute[rbenv global 2.3.3] executed will change from 'false' to 'true'
やったね♪
同じミスが減るように README にプルリク投げてみた。 どうなるかな〜