VAGRANTFILE_API_VERSION = "2" cluster = { "node1" => { :ip => "10.0.0.10", :cpus => 1, :mem => 1024 }, "node2" => { :ip => "10.0.0.20", :cpus => 1, :mem => 1024 }, "node3" => { :ip => "10.0.0.30", :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 = "debian/buster64" 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"] file_to_disk = 'data/' + hostname + '-disk.vdi' unless File.exist?(file_to_disk) vb.customize ['createhd', '--filename', file_to_disk, '--size', 5 * 1024] end vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk] end # end provider config.vm.provision 'shell', path: './data/allnodes.sh' config.vm.provision :hosts, :sync_hosts => true node_script = './data/' + hostname + '.sh' if File.exists?(node_script) then config.vm.provision "file", source: node_script, destination: "$HOME/" else config.vm.provision "shell", inline: "echo SCRIPT not found!" end end # end config end # end cluster end