The Great Feature of Vagrant: Multi-Machine Management

DZone 's Guide to

The Great Feature of Vagrant: Multi-Machine Management

How to utilize Vagrant's ability to improve VirtualBox by managing and repairing your virtual machines.

· DevOps Zone ·
Free Resource

Vagrant allows to be created a development environment that can be distributed. If you have a team that uses different operating systems, it is possible to assemble a virtual environment standard for all.

Vagrant can run with VirtualBox, by VmWare.Image title It can virtually automate the creation of a virtual machine to the virtual box. It can be considered a management tool for virtual machines, and is focused on creating environments that are similar or identical as possible to production servers.

Operating Systems that can be used: Windows, Ubuntu, Debian, and CentOS

Providers: VirtualBox, VmWare, Amazon Web Services.

Image titleProvisioners: Industry standard provisioning tools, such as shell scripts, Chef, Puppet, and Ansible, can be used to install and configure software on the machine automatically.

Reasons for Using Vagrant Over Just VirtualBox

1. Set Up Multi-VM Networks With Ease

Most of the Vagrant power-user content I've read has been about setting up multiple VMs at the same time. Vagrant gives you a single config file to set these up, enabling you to launch all of them with one command.

Say you've configured three VMs to network with each other using static IPs on the 192.168.1.* subnet. You find yourself in a location that is already using that subnet to hand out IP addresses, and your VMs now conflict. With Vagrant, you can simply edit the Vagrantfile and reload the VMs, whereas with VirtualBox you'd have to open the settings for each VM, if not boot each VM and change them inside.

2. Source Control

By putting the settings in a text file, it enables the configuration to be put under source control. Made some changes last week and accidentally broke the image? Just revert the changes and reload the VM. You can accomplish this with VirtualBox snapshots, but it will take up much more space than just a Vagrantfile.

3. Various Platforms

There are a large number of boxes available at sites such as http://vagrantbox.es. This enables you to try various OS's or distributions, applying the same provisioning to set up similar environments. This can help with testing or adding support to new platforms, and would be time-consuming using just VirtualBox.


Vagrant allows you to create portable work environments, which can be easily reproduced on any system. It's useful for developers and system administrators who want to mimic a server's configuration on their local machine. It's useful for teams who want to quickly get designers and project managers up and running with a local installation.

Vagrant is a wrapper, which ties together several components including: virtualization software, such as VirtualBox; and a server base box, such as Ubuntu provisioning tools for configuration management, such as Chef.


The first step in configuring any Vagrant project is to create a Vagrantfile. The purpose of the Vagrantfile is twofold: 

  •  Mark the root directory of your project. A lot of the configuration of Vagrant is relative to this root directory.
  •  Describe the kind of machine and resources you need to run your project, as well as what software to install and how you want to access it.

The Vagrantfile is meant to be committed to version control with your project, if you use version control. This way, every person working with that project can benefit from Vagrant without any upfront work.

VagrantFile Sample

Image title

Puppet Sample

Image title


Vagrant is able define and control multiple guest machines per VagrantFile. These machines are generally able to work together or are somehow associate with each other. Accurately modeling a multi-server production topology, such as separating a web and database server. Modeling a distributed system and how they interact with each other. Testing an interface, such as an API to service component.

VagrantFile to Multi-Machine Sample

Image title

To Access Machines

  1. vagrant up

  2. vagrant ssh n1

  3. vagrant ssh n2


devops ,automation software ,vagrant ,vagrant vm

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}