Vagrant is an open-source software used to build and maintain a portable virtual environment for software development, such as VirtualBox, Hyper-V, Docker containers, Vmware or AWS which try to simplify the software configuration management and virtualisation. It is thus attempting to achieve higher development productivity. Vagrant is written in Ruby, but its ecosystem supports development in different languages, such as PHP, Python, C#, Java or Javascript.

Architecture

Vagrant uses “Provisioners” and “Providers”, as basic principles to manage development environments. Provisioners are tools that allow users to customise the virtual environment configuration. Puppet and Chef are the most used tools in Vagrant (also Ansible is available from 2014).

Providers are services Vagrant uses to set and create a virtual environment. VirtualBox, Hyper-V and Dcker virtualisations are supported directly within Vagrant, Vmware and AWS are then supported using plugins.

Vagrant sits above the virtualisation software as a wrapper helping developers with interactions with providers. It automates the configuration of virtual environment using Chef or Puppet, so the user doesn’t need to use any other virtualisation software directly.

Hardware and software requirements are stored in a file called “Vagrantfile”. It assists with launching necessary steps to produce a “box” ready for development. “Box” is a format and suffix for the Vagrant environment that is copied to another machine to replicate the same environment.

Why to use Vagrant

Local development is appropriate if you develop for yourself and there is no big team involved in development. But if you are working on a bigger project where more teams work and each team needs a different configuration, Vagrant can be a suitable solution. With its help, you can keep all project files and folders in the local environment, but also have them on a server, so it is easy to make the local environment accessible to a project manager or designer.

The advantages of using Vagrant

  • Automation. It is possible to create automated workflow.
  • Accessibility. It is possible to access the instance of Vagrant from other machines.
  • Replication. It allows you to create the same development environment for all team members.
  • Provisioning scripts. It is enough to update the Vagrant file.
  • Multiple servers used. If you have more frontend servers, more backend servers and CDN to install, Vagrant can be very useful. In that case, it is usually difficult to replicate the environment on every machine that developers use. With Vagrant, there is no more to do than to update the configuration file and it automatically creates the environment for you and replicates it wherever you need to.
  • Isolation of dependencies. Using Vagrant, it is possible to isolate dependencies and their configuration into one consistent environment.
  • Testing infrastructure. Using Vagrant, it is possible to quickly built an environment and consistent workflow to test scripts for infrastructure management.
  • Simplification of the designer’s work. The designer can concentrate on his or her work and not dwell unnecessarily on setting the environment.

The disadvantages of using Vagrant

  • The use on small applications isn’t practical. If you work on a small CMS system, Vagrant would rather complicate the situation. But if the application is extensive and you need and automated and distributed environment, it is an appropriate solution.
  • Difficult to learn. The tool is relatively difficult to learn, while other systems, such as Puppet or Chef need to be used.