Se você usar o Vagrant, você pode usar o seguinte Vagrantfile
, que provisionará 3 caixas (Ubuntu 16.04).
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
##############
### References
# - https://www.vagrantup.com/docs/vagrantfile/machine_settings.html
# - https://www.vagrantup.com/docs/vagrantfile/tips.html
# - https://www.vagrantup.com/docs/networking/forwarded_ports.html
##############
#unless Vagrant.has_plugin?("HostManager")
# raise 'HostManager plugin not installed!'
#end
image = "ubuntu/xenial64"
Vagrant.configure("2") do |config|
vboxName1 = "box-101"
hostname1 = "box1"
config.vm.define "#{vboxName1}" do |box|
box.vm.box = "#{image}"
#box.vm.network :private_network, ip: "192.168.56.101"
box.vm.network :public_network, use_dhcp_assigned_default_route: true
box.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 512]
v.customize ["modifyvm", :id, "--name", "#{hostname1}"]
end
end
vboxName2 = "box-102"
hostname2 = "box2"
config.vm.define "#{vboxName2}" do |box|
box.vm.box = "#{image}"
#box.vm.network :private_network, ip: "192.168.56.103"
box.vm.network :public_network, use_dhcp_assigned_default_route: true
box.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 512]
v.customize ["modifyvm", :id, "--name", "#{hostname2}"]
end
end
vboxName3 = "box-103"
hostname3 = "box3"
config.vm.define "#{vboxName3}" do |box|
box.vm.box = "#{image}"
#box.vm.network :private_network, ip: "192.168.56.103"
box.vm.network :public_network, use_dhcp_assigned_default_route: true
box.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 512]
v.customize ["modifyvm", :id, "--name", "#{hostname3}"]
end
end
end
Para usá-lo:
# launches all VMs
$ vagrant up
# ssh into box-101
$ vagrant ssh box-101
Para mais informações sobre o uso de vagrant
, consulte o uso:
$ vagrant