Use Vagrant to Improve Development Environment Setup Time

By Steven J. Vaughan-Nichols

HashiCorp’s utility creates and maintains portable, virtual, software-development environments, plays nice with Chef and Puppet, and can serve as configuration manager, among its many features.

The good news is we now have more development tools than ever. The bad news is we now have more development tools than ever. And, worse still, we need to use different tool sets for every darn project.

How do you manage to keep your development environment and kit together for each project without losing your mind? One great way is with HashiCorp’s Vagrant.

Vagrant is an open-source program for developers. It’s designed to create and maintain portable, virtual, software-development environments.

Its primary developer, Mitchell Hashimoto, explained in a recent SD Times interview he created Vagrant because a client needed some basic, last-minute work on a project. The job only took two hours, but provisioning his laptop to run the right development environment for it took over eight hours.

We’ve been all there. This metawork, the work you need to do on a project before you can actually work on the project, is the bane of many developers.

Hashimoto, thought, as many of us do, “(T)here must be a better way to do this. Does it just need more scripts? Can I automate the install, so I can format my machine really quickly?”

Unlike most of us, however, Hashimoto actually did something about it. “I narrowed it down to this virtualization thing. I hadn’t really used virtualization at this point, I’d just read about it — or used this cloud thing. AWS [Amazon Web Services] was pretty new at the time. I actually chose virtualization primarily because it was free and because I was a frugal college student. That was the genesis of Vagrant.”

That was in 2010 and Vagrant used Oracle Virtualbox for its virtual machine (VM). While VirtualBox is still Vagrant’s default VM, today, you can run Vagrant on almost any VM. This includes Linux’s built-in KVM, Microsoft Hyper-V, and VMware Fusion and VMware Workstation.

You can also run Vagrant in a Docker container. You can even run it, albeit in alpha, in such unusual platforms as Windows Subsystem for Linux. In short, no matter what your operating system, there’s a way to run Vagrant.

According to its website, Vagrant, which is written primarily in Ruby under the liberal MIT License, can be used to develop with essentially any language. It “isolates dependencies and their configuration within a single disposable, consistent environment, without sacrificing any of the tools (editors, browsers, debuggers, etc.) you are used to working with.”

To do this, you create a Vagrantfile written with Ruby syntax. But you really don’t need to know the language since the Vagrantfile consists mostly of simple, variable assignments.

Once you’ve created the Vagrantfile, you just “vagrant” up and “everything is installed and configured for you to work.” Your team members then can create their development environments from the same configuration. So regardless of whether you are working in Linux, Mac OS X or Windows, the entire team is running code in the same environment, “against the same dependencies, all configured the same way,” averting “works on my machine” bugs.

This is no exaggeration. I’ve worked enough with Vagrant to know that once you’ve gotten your development environment set up for a particular project, it is as simple as sliding down a snowy slope to port it from machine to machine and to share it with your fellow developers. It’s really, really handy. This is not hyperbole.

You can also use Vagrant as a configuration management tool. Vagrant also works well with DevOps programs such as Chef and Puppet.

You could, of course, put together your own customized environment with command line interface (CLI) tools. But, as Vagrant’s developers point out, “The difference between these CLI tools and Vagrant is that Vagrant builds on top of these utilities in a number of ways while still providing a consistent workflow.

“Vagrant supports multiple synced folder types, multiple provisioners to setup the machine, automatic SSH setup, creating HTTP tunnels into your development environment, and more. All of these can be configured using a single simple configuration file.”

That isn’t to say creating an environment by hand, the way we’ve done for ages, still doesn’t have its place. But give Vagrant a try, and I think you’ll find it will work better for you nine times out of ten.

Frankly, after using Vagrant, I can’t see ever going back to setting up development environments the old way. It’s so easy to use and saves so much time, I’d never even consider returning to manually configuring developer environments.


Please feel free to share below any comments or insights about your experience with or questions about using Vagrant as software-development environment engine — or configuration manager. And if you found this blog useful, please consider sharing it through social media.


About the blogger: Steven J. Vaughan-Nichols is a veteran IT journalist whose estimable work can be found on a host of channels, including ZDNet.com, PC Magazine, InfoWorld, ComputerWorld, Linux Today and eWEEK. Steven’s IT expertise comes without parallel — he has even been a Jeopardy! clue. And while his views and cloud situations are solely his and don’t necessarily reflect those of Linode, we are grateful for his contributions. He can be followed on Twitter (@sjvn).

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.