VagrantでRuby on Railsの環境構築

VagrantRuby on Railsの作業環境を構築するためのメモ。

事前作業

  • rbenvのインストール
  • Vagrantのインストール
  • Bundleのインストール

Boxを追加

$ mkdir sample && cd sample
$ vagrant init phusion/ubuntu-14.04-amd64
$ vagrant up
$ vagrant ssh

Chefの設定

$ bundle init
gem "chef", "11.12.4"
gem "berkshelf", "3.1.2"
$ bundle install
source "http://api.berkshelf.com"
cookbook 'git'

Chefのレシピを反映

config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = ["./cookbooks"]
    chef.add_recipe 'git'
end
$ vagrant reload
$ vagrant provision

作業中のトラブル

[ERROR] bundle install

Gem::InstallError: berkshelf-api-client requires Ruby version >= 1.9.2.

Bundlerを入れ直す。

[ERROR] bundle exec berks vendor cookbooks

取得先を修正。

source "https://api.berkshelf.com"

参考