Last active
December 17, 2015 18:49
-
-
Save nathwill/5655861 to your computer and use it in GitHub Desktop.
chef-solo multi-vm vagrantfile
This file contains hidden or 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
# vm and role mapping for multi-vm vagrant | |
boxes = [ | |
{ :name => :app, :roles => ['base', 'web'] }, | |
{ :name => :mc, :roles => ['base', 'memcache'] }, | |
{ :name => :db, :roles => ['base', 'db-master'] }, | |
{ :name => :util, :roles => ['base', 'redis', 'resque' ] }, | |
] | |
Vagrant.configure("2") do |config| | |
# base image configuration | |
config.vm.box = "scientific64" | |
config.vm.box_url = "http://lyte.id.au/vagrant/sl6-64-lyte.box" | |
# vagrant-berkshelf hijacks cookbooks_path | |
config.berkshelf.enabled = false | |
# vagrant-omnibus plugin configuration, | |
# permits use of bare images sans chef | |
config.omnibus.chef_version = :latest | |
# vagrant multi-vm configuration | |
boxes.each do |opts| | |
# per node configuration | |
config.vm.define opts[:name] do |node| | |
node.vm.hostname = "%s.vagrant" % opts[:name].to_s | |
# chef-solo configuration | |
node.vm.provision :chef_solo do |chef| | |
chef.cookbooks_path = ["cookbooks", "site-cookbooks"] | |
chef.data_bags_path = "data_bags" | |
chef.roles_path = "roles" | |
opts[:roles].each do |role| | |
chef.add_role("#{role}") | |
end | |
# stop chef-solo from breaking the box | |
chef.json = { | |
"authorization" => { | |
"sudo" => { | |
"users" => [ "vagrant" ], | |
"passwordless" => true, | |
"sudoers_defaults" => ['!requiretty'], | |
} | |
} | |
} | |
end | |
end | |
end | |
end |
Thank you so much for this! It's the only available configuration of chef-solo for multiple-vm's I've found in the whole web!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired by: https://gist.github.com/markba/2404910