4.2.16
http://files.vagrantup.com/packages/0219bb87725aac28a97c0e924c310cc97831fd9d/Vagrant-1.2.4.dmg
MD5 (wheezy.box) = 8611a6e40daf56779134feb783a7f897
curl https://www.dropbox.com/s/ps447hpvfmdjwoy/wheezy.box
vagrant box add wheezy wheezy.box
Vagrant.configure("2") do |config|
config.vm.hostname = "vagrant"
config.vm.box = "wheezy"
config.vm.network :private_network, ip: "33.33.33.33"
config.ssh.max_tries = 40
config.ssh.timeout = 120
config.ssh.forward_agent = true
end
vagrant up
vagrant halt
vagrant destroy
echo 'PATH="$PATH:/Applications/Vagrant/embedded/bin"' >> ~/.bashrc
source ~/.bashrc
# rbenvとかRVMとかが入っている場合は、先頭に追加してください。
gem install berkshelf
# パーミッションのエラーがでるときはsudoで
vagrant plugin install vagrant-berkshelf
berks cookbook handson
cd handson
Vagrant.configure("2") do |config|
config.vm.hostname = "vagrant"
config.vm.box = "wheezy"
config.vm.network :private_network, ip: "33.33.33.33"
config.ssh.max_tries = 40
config.ssh.timeout = 120
config.ssh.forward_agent = true
config.vm.provision :chef_solo do |chef|
chef.run_list = [
"recipe[handson::default]"
]
end
end
編集 recipes/default.rb
include_recipe "apache2"
編集 metadata.rb
depends "apache2", "~> 1.6.0"
vagrant up
or
vagrant provision
# Managed by Chef for <%= node[:hostname] %>
<VirtualHost *:80>
ServerAdmin <%= node[:apache][:contact] %>
DocumentRoot <%= node[:handson][:document_root] %>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory <%= node[:handson][:document_root] %>>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog <%= node[:apache][:log_dir] %>/error.log
LogLevel warn
CustomLog <%= node[:apache][:log_dir] %>/access.log combined
ServerSignature Off
</VirtualHost>
default[:handson][:config] = "static.conf"
default[:handson][:app] = "/srv/static"
default[:handson][:document_root] = "/srv/static"
#
# Cookbook Name:: handson
# Recipe:: default
#
# Copyright (C) 2013 YOUR_NAME
#
# All rights reserved - Do Not Redistribute
#
include_recipe "apache2"
apache_site "000-default" do
enable false
end
directory "/srv/static" do
owner "www-data"
group "www-data"
action :create
mode 00700
end
template "#{node[:handson][:document_root]}/index.html" do
source "index.html.erb"
owner "www-data"
group "www-data"
mode 00766
end
template "#{node[:apache][:dir]}/sites-available/#{node[:handson][:config]}" do
source "apache2.conf.erb"
notifies :restart, 'service[apache2]'
end
apache_site node[:handson][:config] do
enable true
end
hello vagrant
Vagrant.configure("2") do |config|
config.vm.hostname = "vagrant"
config.vm.box = "wheezy"
config.vm.network :private_network, ip: "33.33.33.33"
config.ssh.max_tries = 40
config.ssh.timeout = 120
config.ssh.forward_agent = true
config.berkshelf.enabled = true
config.vm.provision :chef_solo do |chef|
chef.json = {
:mysql => {
:server_root_password => 'root',
:server_debian_password => 'root',
:server_repl_password => 'root',
:bind_address => '0.0.0.0'
}
}
chef.run_list = [
"recipe[handson::default]"
]
end
end
include_recipe "handson::database"
include_recipe "mysql::server"
include_recipe "database::mysql"
mysql_database "handson" do
connection(
:host => "localhost",
:username => "root",
:password => node[:mysql][:server_root_password]
)
action :create
end
mysql_database_user "handson" do
connection(
:host => "localhost",
:username => "root",
:password => node[:mysql][:server_root_password]
)
password "handson"
database_name "handson"
host "localhost"
action [:create, :grant]
end
depends "mysql", "~> 3.0.0"
depends "database", "~> 1.3.0"