ItamaeのレシピをVagrantに流し込んで環境構築
Itamaeを使ってVagrantの環境構築をするためのgemとして、vagrant-itamaeというものを作ってくださってるようなので、これを使います。
https://github.com/chiastolite/vagrant-itamae
vagrantにpluginとしてインストールします。
$ vagrant plugin install vagrant-itamae
Vagrantfileに、以下のように追加します。
Vagrant.configure('2') do |config| # ... config.vm.provision :itamae do |config| config.sudo = true config.shell = "/bin/sh" config.recipes = ["./recipes/recipes/base.rb"] config.json = "./recipes/nodes/node.json" end end
これであとは$ vagrant up
すれば自動的にレシピが走ってくれます。ShellScriptでやってたのだけど、こっちの方がRubyで書けてメンテナブルだし、いろいろ使い回せるのでいい感じ。
一度以下のようなエラーで落ちてしまいました。
/path/to/itamae/itamae/backend.rb:181:in `build_command': undefined method `shellescape' for nil:NilClass (NoMethodError)
ググったら、ここで解決しました。ありがたや。。。