decadence

個人のメモ帳

Vagrantの適当な環境用意する

Qiitaとかその辺に記事あるしハマりどころも無いし,個人のメモ

追記
vagrant-berkshelf非推奨だった
追記終わり

Berkshelf 使うと楽だった
https://github.com/opscode-cookbooks/ にある chef のレシピをパパって持ってきてくれるやつ

ちゃんとイジる必要あるなら,自分でレシピ書くも良し,fork していじって submodule にしても良し

準備

vagrant plugin install vagrant-omnibus // 最新の chef とか手軽に使えるようにするやつ(ついで)
vagrant plugin install vagrant-berkshelf

vagrant-berkshelf 今なんかおかしいので,この辺なら以下のように解決出来る

git clone git@github.com:chulkilee/vagrant-berkshelf.git
cd vagrant-berkshelf/
git checkout vagrant-1.5
gem build vagrant-berkshelf.gemspec
vagrant plugin install vagrant-berkshelf-1.4.0.dev1.gem

Gemfileの中身

source 'https://rubygems.org'

gem 'berkshelf'

テンプレみたいなの berks で作ってもらう

bundle install
bundle exec berks cookbook mybox
cd mybox

設定

Berksfileの中身
ここにあるの全て使えるし,適宜url指定しても良いし

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

metadata

cookbook "apt"
cookbook "mysql"

cookbooksってフォルダに突っ込む

bundle exec berks vendor cookbooks

Vagrantfile こんな感じ

#...
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  #...
  config.omnibus.chef_version = :latest
  config.berkshelf.enabled = true

  config.vm.provision :chef_solo do |chef|
    chef.json = {
      mysql: {
        server_root_password: "vagrant",
        server_debian_password: "vagrant",
        server_repl_password: "vagrant"
      }
    }

    chef.run_list = [
      "recipe[apt]",
      "recipe[mysql::client]",
      "recipe[mysql::server]",
    ]
end

起動しつつ必要なら --provision しつつ

vagrant up