What is Vagrant ?

Vagrant is a tool for providing repeatable work environments running on VirtualBox, KVM, OpenStack, Amazon Web Services (AWS), Softlayer, Rackspace among others. The most common use case is to create a virtual machine (VM) environment on VirtualBox or KVM or VMware. However, with support for OpenStack, Softlayer and other providers, there is a possibility to even create bare-metal work environments, since Vagrant in this case will be just calling the relevant  provider APIs.

Vagrant tries to solve the following major problems from a developer point of view :

  • How to easily and quickly create a consistent and repeatable development environment for all the team members?
    • All team members use the same development environment irrespective of whether they are working on Linux or Windows or Mac. Vagrant makes use of virtualization to create the development environment.
  • How to ensure, that the dependencies and configurations are in sync between development, test and production environments?
    • Many a time, due to inconsistencies between the development and production environments, while the code works in development environment, it breaks in production environment. Vagrant provides the flexibility to use the same configuration mechanisms for development and production.

Vagrant tries to solve the following major problems from an operations engineer point of view:

  • How to ensure that the application dependencies and runtime environment configurations are the same as used for development and testing ?
  • How to test the infrastructure configuration scripts locally as well as on the actual environment ?
    • Vagrant helps to develop and test infrastructure management scripts both locally using Virtualbox or KVM and remotely using AWS, Softlayer etc.

Key Components

1. Vagrantfile – This is the Vagrant environment description file. It contains a set of instructions, which Vagrant uses to create and configure the environment. Vagrant supports only one Vagrantfile per project and as a best practice, should be version controlled. Vagrantfile follows Ruby syntax.


Vagrant.configure("2") do |config|
  config.vm.define :test_vm do |test_vm|
    test_vm.vm.box = "precise64"

2. Provisioners – This is the component responsible for configuring the environment – package installation, configuration etc. It supports shell scripts, puppet manifests, chef recipes or anisble playbooks.

Eg, the following line in the Vagrantfile instructs Vagrant to use the ‘shell’ provisioner.

config.vm.provision “shell”, path: “setup.sh”

setup.sh is the script which will be run by Vagrant post environment creation.

3. Box – this is the template, which forms the initial seed for the environment. A box can be versioned as well.

4. Providers – this is the underlying platform, where the environment will be created. Vagrant supports VirtualBox, libvirt/KVM, VMware, AWS, OpenStack, Softlayer, Rackspace and many other providers. VirtualBox is the default provider and comes as part of Vagrant. The remaining providers are available as plugins, and need to be installed. For example, this is how one need to install the libvirt provider plugin.

$vagrant plugin install vagrant-libvirt

Vagrant Workflow

At a high level a typical Vagrant workflow looks like the following:


Common Commands

The following three commands are most commonly used in a typical Vagrant workflow :

1. ‘vagrant up’  : Create a work environment

2. ‘vagrant destroy’  :  Destroy a work environment

3. ‘vagrant ssh’ : SSH to the work environment

Hope this gives a good overview of Vagrant. For more details please refer to https://www.vagrantup.com/.

If you have not tried Vagrant, suggest you please give it a try. This is one tool which will make your life  much simpler :-).

Pradipta Kumar Banerjee

I'm a Cloud and Linux/ OpenSource enthusiast, with 16 years of industry experience at IBM. You can find more details about me here - Linkedin

You may also like...