Vagrant: Up and Running
Mitchell Hashimoto
Beijing Cambridge Farnham Kln Sebastopol Tokyo
Foreword
Jeff Sussna
Founder and Principal, Ingineering.IT
Every so often, you encounter software that immediately strikes you with its combination of clarity, simplicity, power, and usefulness. You simultaneously say wow! and why didnt I think of that? But you couldnt have thought of it. It needs an author who can conceive and implement that particular vision, not just appreciate it. Vagrant is that kind of software, and Mitchell Hashimoto is that kind of author.
Software as a service dramatically lowers the cost of change for its users. As a result, they come to expect near-instantaneous responsiveness from software vendors. The ability to continuously deliver new features is taking its place alongside the features themselves as a competitive advantage. Service providers face the conundrum of needing to accelerate velocity without sacrificing quality. Vagrant provides a critical contribution to solving that problem.
Agility experts often talk about John Boyds OODA (Observe-Orient-Decide-Act) Loop. An Air Force pilot, Boyd developed the OODA Loop concept to describe the process of reacting to an enemy during airborne battle. Victory came from getting inside your enemys OODA Loopin other words, being able to react, respond, and change more quickly than your enemy.
Approaching software delivery as a form of battle requiring fast reflexes conjures up visions of fear, tension, and sweat. But fear and tension lead to mistakes (aka bugs). How do you get inside your competitions OODA Loop without working 24 hours a day or permanently raising your blood pressure? The answer lies in automation.
Automation lets you wring unnecessary manual effort, along with opportunities for mistakes, out of the process. It also allows you to move faster without worrying about getting things wrong or leaving things out. Consistent automation throughout the software lifecycle further reduces chances of mistakes due to variation. If you test your software against exactly the same system configuration thats running in production, youre more likely to catch the right bugs, and less likely to waste time fixing the wrong ones.
Vagrant brings configuration automation all the way down to the developers desktop. With it, you can package the same operating system that runs in productionalong with the same configuration automation scriptsin a form thats easily shared among developers. Instead of spending the first two days on the job installing software, a new development team member can spin up a production-identical environment on their laptop simply by typing vagrant init
then vagrant up
.
With Vagrant, a new developer can get started delivering value in an hour instead of a day. All the developers on the team can update their environments with a new software version in minutes, instead of hours, simply by typing vagrant provision
. Then they can all get back to valuable work, secure inthe knowledge theyre all building against the same version as production and as each other. In other words, they can go faster, without fear.
I like to think of Vagrant as the Git of development clouds. Centralized development and test environments create bottlenecks. Vagrant lets developers work at their own pace and in their own environment, while keeping all the environments synchronized with each other. Flexibility joined with consistency is the best and sanest way to tighten a teams OODA Loop.
Finally, in addition to writing great software, Mitchell has always done a good job of writing documentation. The Getting Started tutorial on the Vagrant website is a great way towell, get started. This book continues the tradition of helpful Vagrant documentation. Its useful for beginners and experts alike. It does a great job of balancing basic concepts with behind-the-scenes technical details. Even experienced Vagrant users will learn some new tricks. Just as Vagrant belongs in your Continuous Delivery toolkit, so too Vagrant: Up and Running belongs on your bookshelf.
Preface
Vagrant is quickly becoming a must-have tool in every software and operation engineers toolbox. Used by tens of thousands of companies, the Vagrant workflow is a familiar and highly praised way to build, manage, and distribute automatically created development and test environments. These environments are identical whether youre working on Mac OS X, Windows, or Linux.
Vagrant takes the cloud, a revolutionary movement founded on the idea of cheap, disposable computing resources, and makes this idea available on anyones desktop. With just two commands and zero configuration, Vagrant automatically builds and configures a fully featured virtual machine for any purpose.
And with just a little bit of easy-to-learn configuration, Vagrant can automatically set up complex network configurations, install and manage software within the virtual machine, or package the virtual machine for re-use by other people.
Virtualization is the foundational technology behind what is often referred to as the cloud. Amazon Web Services, Microsoft Azure, virtual private server (VPS) providers, and more are based completely around this technology or those similar to it. These sort of cloud services are now the de facto standard for hosting web applications.
Virtualization is everywhere. The good news is that virtualization technology is readily available to anyone with a modern computer. The bad news is that were only at the tip of the iceberg of what is possible with this technology. Vagrant is here to change this.
In early 2010, I worked for a web development consultancy and was frustrated by having to repeatedly set up development environments manually for various projects. I approached John Bender, who was facing similar frustrations at the time, and the project was started.
The first version of Vagrant was released in March 2010. From the beginning, Vagrant was open sourced under the MIT license. In October 2010, Engine Yard announced that they were going to sponsor the Vagrant project. With the support from Engine Yard, I was able to travel around the country to various conferences and speak about Vagrant.
Slowly, more and more people started to use and talk about Vagrant. These early adopters of Vagrant were active in reporting bugs, requesting features, and pointing out any improvements that could be made. Hundreds of early users contributed code and documentation back to the project.
Vagrant 1.0, the first stable version, was released in March 2012, exactly two years after the original version of Vagrant. Despite not releasing an official stable release prior, hundreds of companies were already using Vagrant at that point and had proven 1.0 to be stable.
Today, Vagrant is used by companies worldwide who have found great benefits in integrating Vagrant into their developer or operations workflows. It is difficult to attend any cloud or IT infrastructure conference without hearing Vagrant mentioned or discussed. And yet, Vagrant is still very young. I have full confidence that in just a few more years, Vagrant will become a necessary tool for any developer or operations engineer.
At the time of writing, Vagrant continues to improve and innovate, adding new features and fixing old issues. Despite these changes, Vagrant promises to remain backward-compatible with valid configurations from version 1.0 (the stable release). In an effort to make sure that this book also remains as stable as possible, I will cover the configuration and features of Vagrant 1.0 while running on top of the latest version of Vagrant for maximum stability. This means that some of the latest features may not be covered in this book yet, because they are still evolving and are prone to change. But the proven featuresthe foundational features that made Vagrant 1.0 and continue to be critical to all aspects of Vagrant usageare the features that are covered in great detail in this book.