Skip to content

Instantly share code, notes, and snippets.

@jaymecd
Created August 13, 2013 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaymecd/6225796 to your computer and use it in GitHub Desktop.
Save jaymecd/6225796 to your computer and use it in GitHub Desktop.
Multiboxes Vagrantfile
# Run before: $ vagrant plugin install vagrant-hosts
domain = 'dev'
boxes = {
"wheezy64" => "https://s3-eu-west-1.amazonaws.com/ffuenf-vagrant-boxes/chef-11.6.0/debian-7.1.0-amd64.box",
"precise64" => "http://files.vagrantup.com/precise64.box",
}
nodes = [
{:hostname => "node01", :ip => "192.168.56.10", :box => "wheezy64", :ram => 512},
{:hostname => "node02", :ip => "192.168.56.11", :box => "precise64"},
]
Vagrant.configure("2") do |config|
config.ssh.forward_agent = true
config.ssh.keep_alive = true
# share hosts/ip between nodes
config.vm.provision :hosts do |host|
nodes.each do |node|
host.add_host node[:ip], [node[:hostname] + "." + domain]
end
end
nodes.each do |node|
config.vm.define node[:hostname] do |node_config|
node_config.vm.box = node[:box]
node_config.vm.box_url = boxes[node[:box]]
node_config.vm.hostname = node[:hostname] + "." + domain
node_config.vm.network :private_network, :ip => node[:ip]
node_config.vm.provider :virtualbox do |vb, orig|
vb.customize [
"modifyvm", :id,
"--name", node[:hostname],
"--memory", (node[:ram] || 384).to_s,
"--cpus", 1,
"--cpuexecutioncap", "75",
"--natdnshostresolver1", "on"
]
end
provision = "provision/" + node[:hostname]
if node[:hostname] = "node01"
node_config.vm.provision :puppet do |puppet|
puppet.manifests_path = provision + "/manifests"
puppet.module_path = provision + "/modules"
puppet.options = "--verbose --debug"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment