Skip to content

Instantly share code, notes, and snippets.

@rrichards
Forked from roblayton/Vagrantfile
Created November 6, 2020 17:43
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 rrichards/dfb66c4affdf3ef6ff8ce7a5afa031d0 to your computer and use it in GitHub Desktop.
Save rrichards/dfb66c4affdf3ef6ff8ce7a5afa031d0 to your computer and use it in GitHub Desktop.
A Vagrant multi-machine cluster using a loop
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
cluster = {
"master" => { :ip => "192.168.33.10", :cpus => 1, :mem => 1024 },
"slave" => { :ip => "192.168.33.11", :cpus => 1, :mem => 1024 }
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
cluster.each_with_index do |(hostname, info), index|
config.vm.define hostname do |cfg|
cfg.vm.provider :virtualbox do |vb, override|
config.vm.box = "ubuntu/trusty64"
override.vm.network :private_network, ip: "#{info[:ip]}"
override.vm.hostname = hostname
vb.name = hostname
vb.customize ["modifyvm", :id, "--memory", info[:mem], "--cpus", info[:cpus], "--hwvirtex", "on"]
end # end provider
end # end config
end # end cluster
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment