Skip to content

Instantly share code, notes, and snippets.

@nathwill
Last active December 17, 2015 18:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathwill/5655861 to your computer and use it in GitHub Desktop.
Save nathwill/5655861 to your computer and use it in GitHub Desktop.
chef-solo multi-vm vagrantfile
# 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
@nathwill
Copy link
Author

@holms
Copy link

holms commented Feb 22, 2014

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