VagrantのプロビジョニングでChef Soloを使ってみる その2
ちょっと整理してリベンジ
環境
$ vagrant version Installed Version: 1.6.3 Latest Version: 1.6.3 You're running an up-to-date version of Vagrant! $ vagrant plugin list sahara (0.0.16) vagrant-berkshelf (2.0.1) - Version Constraint: >= 2.0.1 vagrant-login (1.0.1, system) vagrant-omnibus (1.4.1) vagrant-share (1.1.0, system)
今回はBerkshelfのVagrantfileを使います。
まずは初期化、これは前回と同様です。
$ berks cookbook sample
まずはBerksfile
にmysql と nginxのcookbookを追加
source "https://api.berkshelf.com" metadata cookbook "mysql" cookbook "nginx", "~> 2.6"
Vagrantfileのrun_listにcookbookを追加
- config.vm.box = "opscode_ubuntu-12.04_provisionerless" + config.vm.box = "centos6.5" - config.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box" + config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box" mysql: { server_root_password: 'rootpass', - server_debian_password: 'debpass', - server_repl_password: 'replpass' + server_repl_password: 'replpass', + bind_address: "127.0.0.1" } } chef.run_list = [ + "nginx", + "mysql::client", + "mysql::server", "recipe[sample::default]" ]
sample/recipes/default.rb
もちょっと試してみる
log "Hello World!!!!!!!!!!!!!"
あとはvagrant up
すればmysql,nginx,hello worldそれぞれが実行されて起動してくれる。
ただ、Barkshelfの使い方ってこれであってるの?って感じ。
chefはそこそこにansible試してみたいのでそっちは時間があったらもうちょっと勉強する