computer with digital information floating from screen into air

It’s a problem all too familiar to software developers. Sometimes the job itself doesn’t take anywhere near as long as it does to set up all the tools, libraries, frameworks, and technologies that go into a new development environment. Then there’s the larger problem of keeping work environments consistent and up-to-date across teams of developers, designers, and operators. Inconsistencies across development environments are the number-one cause of the infamous “it works on my machine” bug.

The solution? Vagrant—a tool that specializes in using virtual machines (VM) to set up lightweight, reproducible, and portable development environments. Let’s dive into the details of how Vagrant can boost productivity at your organization.

Reduce project startup times

You’ve probably heard Vagrant’s fanbase talking about how easy it is to “Vagrant up” a new development environment. It turns out the catchphrase is more than just lingo. Setting up a virtual environment in Vagrant really is as simple as typing two lines into your CLI of choice:

$ vagrant init hashicorp/precise64
$ vagrant up

These two commands will set up a fully functional VM in VirtualBox running Ubuntu 12.04 LTS 64-bit. Running “vagrant init” in your own preexisting project directory is all it takes to start up a project. Besides VirtualBox, Vagrant can run on almost any other VM out there, including VMware, Hyper-V, and Amazon Web Services (AWS).

Configuration made easy with Vagrantfiles

As you might have guessed, before you can “Vagrant up” a new project, a bit of setup is required. Every project starts with a Vagrantfile, which marks the root directory of your project. It’s where you’ll describe the VM and resources (software, installation paths, etc.) needed to run your project. While the file is written in Ruby, knowledge of Ruby is not required, because all you’ll really be doing is declaring variables. Teams will usually commit their Vagrantfile to a version control system such as Git, giving every person working on that project access to the same workstation.

Plug-and-play virtual environments with Vagrant boxes

Once you’ve set up your Vagrantfile, the magic begins. Instead of building a virtual machine from scratch, you can point to a base image called a box that will quickly clone an existing VM. You can download a ready-to-use development environment from HashiCorp’s Vagrant Cloud box catalog and add it to your configuration settings within your Vagrantfile. Or you can go through the trouble of setting up your own virtual environment and route to it directly. The important thing is that once you’ve set up a work environment, you can easily use it across multiple projects and bring new team members up to speed, no matter what operating systems (Mac, Windows, or Linux) their physical workstations are running.

Provisioning with Vagrant

Vagrant ships with out-of-the-box support for VirtualBox, Hyper-V, and Docker. But here are some other popular ways to provision virtual environments with Vagrant:

You can use these common provisioning tools to automatically install and configure software running on your virtual machine.

Vagrant up your next software development project

Hopefully, this article was able to demonstrate how Vagrant can help you set up portable software development environments for your projects:

  • Developers get a consistent, disposable environment that isolates core dependencies and configuration settings for a project that they can build on top of with their preferred tools (editors, browsers, debuggers, etc.).
  • Designers get to focus on designing; they can simply check out code, Vagrant up, and design within an environment already configured by a developer.
  • DevOps engineers get a single tool from which to manage all the virtual environments used by the team and a test environment that remains consistent throughout the entire software development workflow from continuous integration (CI) through continuous delivery (CD) to deployment.

Eager to learn more about Vagrant? Check out the official documentation for an excellent getting-started guide and Vagrant up your first virtual environment. Looking for more tips on DevOps tools? Check out the Hiring Headquarters for more articles on DevOps.

Upwork is a freelancing website where businesses of all sizes can find talented professionals across multiple disciplines and categories. If you are a business and are looking to get projects done, consider signing up!