Category Archives: Virtualization

“But it Works on My Box” – A Case for Vagrant

When I need to quickly spin up a server to do testing, debugging, development, etc., I usually spin up VirtualBox and build a VM based off a cloud image file from scratch. It is a tedious process but I figured it’s easy and quick to just clone the VM afterwards. The problem arises when I want to share this environment with my contract workers or other members of my team. These images tend to be large as they include the OS, disks, hardware configuration, etc.

Enter Vagrant.

Vagrant isn’t exactly a competitor to VirtualBox but more of a wrapper. It’s basically a VM manager.

Benefits of Vagrant:

  • You could check in the Vagrant files into source control with your project (e.g., Git) and a user can have an identical environment by running a single command “vagrant up”
    • You don’t have to share a 500MB+ VM image file. You only need two small files (Vagrantfile & a provision script)
    • Keeps absolute parity between all collaborators on a project. All they have to do is pull the source code and “vagrant up”
    • You could integrate with several Configuration Management systems such as Chef, Ansible, and Puppet for provisioning.
    • You could have different Virtual Machines for different purposes
    • The configuration is in plain-text so you have an idea of what kind of hardware is required to run the application and which apps will be installed.
  • It could manage and spin up multiple VM instances
    • If you need multiple servers for load-balancing web servers, clustering databases, etc. All you have to do is add these servers to the Vagrantfile and “vagrant up”
    • Simplifies multi-VM networks
    • It makes setting up a distributed system development environment very easy.
    • Centralized configuration of all VMs
  • Faster to setup a VM
    • Much quicker to get a VM up and running than on VirtualBox
    • Networking is automated
  • Share the environment
    • You could easily have users connect directly to your host via http, ssh, and custom ports.
  • You could manage other types of machines with Providers
    • VirtualBox
    • VMWare
    • AWS
    • GCE
  • You don’t have to change your development environment
    • Vagrant makes the code files seamless from the host to the guest. You could use your own OS, editor, browser, and other development tools.

In the end, Vagrant saves a lot of time and it’s easy to get started with. Keep in mind VMs do require actual hardware allocations and there could be limitations on your machine. If you need to run a large number of VMs, use Docker.