Vagrant boot multiple virtual machines
Vagrant is excellent tool for creating easily new virtual machines. It takes less than 1 minute (image downloading take some times) getting vagrant up. If you would like to management multiple virtual machines easily select vagrant. In this instructions we create first new virtual machine and after that we build same time multiple virtual machines.
Install Vagrant
$ sudo apt-get -y install vagrant virtualbox
Next you download Ubuntu 14.04 (trusty32) box (like vagrant call their images). When we add image to box vagrant keep its in the memory, and we could then use it to later:
$ vagrant box add trusty32 http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box
Generating vagrant's initializing file. Vagrantfile generating in to same directory where you give that command. Vagrantfile include config class which tell vagrant what you want to do with it. Now we just want to do only one virtual machine, but later we have to little bit modify this config-file, if we want to building up multiple virtual machines:
$ vagrant init trusty32
Set Vagrant up
$ vagrant up
And take connect to vagrant by ssh:
$ vagrant ssh
If you want destroy our virtual machine, you could give command:
$ vagrant destroy
Multiple virtual machines
Now we are successfully create new virtual machine. But, we want something more. We would like to create multiple virtual machines. First we have little modify our config vagrantfile.
$ nano Vagrantfile
And Vagrantfile code is:
Vagrant::Config.run do |config|
config.vm.define "virtual1" do |v|
v.vm.box = "trusty32"
end
config.vm.define "virtual2" do |v|
v.vm.box = "trusty32"
end
end
We made two virtual machines "virtual1" and "virtual2". Line v.vm.box = "trusty32" tell that we use trusty32 box.
Set up multiple Vagrants
$ vagrant up
Virtual machines getting up, and when they are ready you can take connect to them by command:
$ vagrant ssh virtual1
or
$ vagrant ssh virtual2
And you can destroy them by command:
$ vagrant destroy
Source
http://docs.vagrantup.com/v2/multi-machine/
http://terokarvinen.com/2012/vagrant-ubuntu-12-04-create-boot-new-virtual-machine-vagrant-ssh-virtualbox-apt-get
EDIT 2014-10-05: Update precise32 (Ubuntu 12.04) to trusty32 (Ubuntu 14.04).