Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage Articles Book Review: Vagrant up and running

Book Review: Vagrant up and running

Mitchell Hashimoto released his book "Vagrant up and running" which covers everything from basic Vagrant usage to extending its functionality.

In chapter one, Mitchell describes "The Tao of Vagrant" - his opinion on the most powerful way of using Vagrant.

He describes how developers or operations engineers can check out their projects from version control and execute "vagrant up" to create fully running systems.

Vagrant also enables easy rollbacks via "vagrant destroy". This ensures all changes to an environment are reverted and issuing a "vagrant up" let's you start from scratch.

After explaining the basic workflow, Mitchell shows how Vagrant compares to alternatives like plain desktop virtualization, container-based solutions like LXC and developing directly in the cloud.

These alternatives work, but, compared to Vagrant, miss the simplicity and the unified way of dealing with your environments. Since version 1.1, Vagrant even supports most alternative solutions via its new plugin system.

Mitchell closes the first chapter with installation instructions. When installing Vagrant 1.1, you need to make sure that you don't have any Vagrant version installed using RubyGems first, as it might lead to conflicts with the Vagrant installer.

In chapter two, Mitchell gets you started with your first Vagrant machine. He shows you how to start a new project by running "vagrant init", and, the simplest way to connect to your Vagrant machine, "vagrant ssh".

He covers the basics of the Vagrantfile - a simple text file you create per project to configure how you want to use Vagrant.

Every Vagrant machine uses a so-called "Box" as the base image for your Virtual Machine (VM). He describes what boxes are and that their large disk images are shared between projects, so you don't need to download them multiple times.

After showing how a Vagrant machine boots, he introduces the basic ways of working with the machine like using ssh, basic networking and shared folders. Every aspect is covered in greater detail later in the book.

The third chapter talks about provisioning your Vagrant VMs. To destroy and re-create VMs easily, you'll need a fully automated way to install all required software and configure the system as needed.

He shows a very basic way of getting started with automated provisioning including basic examples using shell scripts, Chef and Puppet.

While using provisioners is an important topic, this chapter is nothing more than an introduction. Chef and Puppet are fully blown Configuration Management solutions which fill books by themselves.

In chapter four, Mitchell describes all the possible networking modes Vagrant supports. He goes into details of port forwarding, host-only networking, and bridged networking.

He discusses the pros and cons of every approach so that the reader can decide which networking mode might suit best. This chapter provides a foundation to chapter five and multimachine clusters.

Vagrant is able to start multiple machines configured in the same Vagrantfile with a single command. Mitchell discusses how to control multiple machines: by naming a machine and appending the its name to any Vagrant command, you instruct Vagrant to apply the command to only that machine. Omitting a machine name when calling a vagrant command will apply it to all machines in your cluster.

After demonstrating the basic handling of multimachine clusters, Mitchell introduces the reader to several networking options for working with your machines. He finishes chapter five with a real world example using MySQL.

Chapter six talks dives into the details of Boxes. Mitchell discusses the rationale behind boxes: boxes give you a high level starting point for provisioning instead of a full OS install with every "vagrant up".

After discussing the "why" of boxes, Mitchell introduces the reader to the Box format and showing you how to create and package Boxes. He closes the chapter with the creation of a default Vagrantfile for your Boxes.

Chapter seven covers the most advanced topic: extending Vagrant with plug-ins.

Vagrant offers a plug-in system where you can extend features, add custom commands or new configuration options, setup custom provisioners, or even modify existing Vagrant behavior. Mitchell has advanced examples for each case showing you everything to get started developing your own extensions for Vagrant. The chapter describes how to set up your development environment and perform error handling and validation.

Mitchell's "Vagrant up and running" gets you started with Vagrant, explaining all the important concepts needed to leverage your VMs, and demonstrating how to extend Vagrant yourself.

About the Book Author

Mitchell Hashimoto is a passionate engineer, professional speaker, and entrepreneur. Mitchell has been creating and contributing to open source software for almost a decade. Mitchell speaks at dozens of conferences about his work, such as VelocityConf, OSCON, FOSDEM, and more. Mitchell is the founder of HashiCorp, a company whose goal is to make the best DevOps tools in the world, including Vagrant. Prior to HashiCorp, Mitchell spent five years as a web developer and another four as an operations engineer.

Rate this Article