Running multiple instances of Vagrant VM

Today, I hit with a scenario where I wanted to setup a Mediawiki -Mail server model, so that I can test the working of the main email system. My goal was to implement the handling of mail bounces using VERP as part of my GSoC proposal. My mentors suggested that I should be able to mange two VM’s in vagrant – one running the MediaWiki web- server, which will send the mail with the help of the inbuilt php functions and the other box, which would run a plain installation of Ubuntu with a mail-server installed -Exim4. Exim4 is used by the MediaWiki servers.
Setting up two vagrant instances was the difficult part. I am explaining, how I went through.You can get the Mediawiki Vagrant from here .
Now, the usual steps for a single instance vagrant-for-MWiki, as given  is to clone the repo, get inside, and give vagrant up. So, inorder to run multiple instances, we need to understand clearly what happens on vagrant up.

Now, every vagrant has a VagrantFile, which basically controls what all goes inside the box, or what all needs to come up, when ‘vagrant up’ is given.Going through the vagrantfile  , you can see that
Vagrant.configure('2') do |config|
is the main function under which the default configurations for the linux is written. Now, going through ( will show exactly how to add the two servers.

/* The boxes I need to add are named “webserver” and “mail”
*I need to have both the VM’s under the same private network, so that they will communicate.
*Therefore, I need to assign Box#1 with amd Box#2 with
*Make sure you change all required to
*Make sure you give different forwarded_port to both of your installations.
*Consider giving 1024 to first and 1025 to second better delete the declaration
*FORWARDED_PORT = 8080 line, and just substitute it with the corresponding port numbers.

Now, inorder to append the existing Vagrant file :

Vagrant.configure('2') do |config|
config.vm.define "webserver" do |webserver|
config.vm.hostname = '' = 'precise-cloud' :private_network,
ip: ''

and continue it till

puppet.facter = $FACTER = {
'fqdn' => config.vm.hostname,
'forwarded_port' => 1240,
'shared_apt_cache' => '/vagrant/apt-cache/',

after which, add the configurations for your second “mail” box:-

config.vm.define "mail" do |mail| = 'precise-cloud'
config.vm.hostname = 'eximmail' :private_network,
ip: '' :forwarded_port,
guest: 80, host:1250, id: 'http'

and copy all the code from above from

 # www-data needs .. to
'shared_apt_cache' => '/vagrant/apt-cache/',

so that it will have all the properties of the other VM.
And at the last, make sure you end the box configs.
Now, fire up the separate boxes with the commands:

vagrant up webserver
vagrant up mail

Now, follow instructions in ( to install the LinuxGuestAdditions.Any queries, please comment.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s