How to define multiple Vagrant VMs within one VagrantFile
My colleague Luiz Casey and I were discussing how to configure multiple Vagrant configuration within one Vagrantfile, and he tracked down Mr. Vagrant himself, Mitchell Hashimoto, on IRC. Ends up looking like this:
Vagrant::Config.run do |config|
config.vm.define :centos5 do |centos5_config|
centos5_config.vm.box = "opscode-centos-5"
centos5_config.vm.provision :chef_client do |chef|
chef.chef_server_url = "https://api.opscode.com/organizations/aarp"
chef.validation_key_path = "~/.chef/aarp-validator.pem"
chef.validation_client_name = "aarp-validator"
chef.node_name = "opscode-centos32-5-aarp"
chef.provisioning_path = "/etc/chef"
chef.log_level = :info
end
end
config.vm.define :lucid do |lucid_config|
lucid_config.vm.box = "ubuntu10.04-gems"
lucid_config.vm.provision :chef_client do |chef|
chef.chef_server_url = "https://api.opscode.com/organizations/aarp"
chef.validation_key_path = "~/.chef/aarp-validator.pem"
chef.validation_client_name = "aarp-validator"
chef.node_name = 'opscode-lucid32-aarp'
chef.provisioning_path = "/etc/chef"
chef.log_level = :info
end
end
config.vm.customize do |vm|
vm.memory_size = 2048
end
end
To start a single instance:
vagrant up lucid
Current bug if a node is already provisioned it will try to provision the node. It will still start up just take a bit longer.
http://groups.google.com/group/vagrant-up/browse_thread/thread/67f6a58cc7c89b58
--no-provision flag
Leave a Comment