Created
November 29, 2012 19:45
-
-
Save iturgeon/4171379 to your computer and use it in GitHub Desktop.
Chef and Vagrant setup to easily create databases as needed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create all the databases from the Vagrantfile json config | |
node[:db].each do |env, name| | |
execute "create database #{name}" do | |
command "mysql -uroot -p#{node[:mysql][:server_root_password]} -e 'create database if not exists #{name}'" | |
user "vagrant" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant::Config.run do |config| | |
config.vm.box = "lucid32" | |
config.vm.box_url = "http://files.vagrantup.com/lucid32.box" | |
config.vm.provision :chef_solo do |chef| | |
chef.cookbooks_path = "cookbooks" | |
# pass json_attribs to chef | |
chef.json = { | |
"development" => true, | |
"mysql" => { | |
"server_root_password" => "<PW>", | |
"allow_remote_root" => true, | |
"bind_address" => "0.0.0.0", | |
}, | |
"db" => { | |
"prod" => "db_prod", | |
"test" => "db_test", | |
"dev" => "db_dev" | |
} | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just what I needed! cheers!