Vagrant.configure("2") do |config| servers=[ { :hostname => "db01", :box => "bento/ubuntu-21.10", :ip => "10.0.2.16", :ssh_port => '2210' }, { :hostname => "web01", :box => "bento/ubuntu-21.10", :ip => "10.0.2.17", :ssh_port => '2211' }, { :hostname => "web02", :box => "bento/ubuntu-21.10", :ip => "10.0.2.18", :ssh_port => '2212' }, { :hostname => "loadbalancer", :box => "bento/ubuntu-21.10", :ip => "10.0.2.19", :ssh_port => '2213' } ] servers.each do |machine| config.vm.define machine[:hostname] do |node| node.vm.box = machine[:box] node.vm.hostname = machine[:hostname] node.vm.network :private_network, ip: machine[:ip] node.vm.network "forwarded_port", guest: 22, host: machine[:ssh_port], id: "ssh" node.vm.provider :virtualbox do |v| v.customize ["modifyvm", :id, "--memory", 512] v.customize ["modifyvm", :id, "--name", machine[:hostname]] end end end end