A practical guide to Vagrant

Portable environments for effective development

How many times did you hear the excuse "works on my machine"? With Vagrant, this stays in the past. Your environments will be exactly the way you want them to be, targeting specific projects for different needs. As easy as cloning a repository and running "vagrant up".

This book covers from basic to advanced concepts on Vagrant, including important ProTips to improve your Vagrant projects and avoid common mistakes. The book was updated to cover the new features on Vagrant 1.5 and 1.6.


Vagrant Cookbook comes with quick guides to the 3 most used Vagrant provisioners: Puppet, Ansible and Chef. Following the guide, a practical example will show you how to provision a basic web server with Nginx + PHP5-FPM (PHP 5.5+). Choose the one you like best!

Recipes for most common tasks

The book also includes useful recipes for common tasks, writen in Ansible, Puppet and Chef.

Code Samples

The complete provisioner examples are available for free on GitHub.


Vagrant Cookbook targets beginner to intermediate users, also serving as a quick getting-started guide for Ansible, Puppet and Chef.


Thanks to the LeanPub platform, is really easy to release updates and notify my readers. Obviously at no extra cost. For any new content / corrections, you will be notified to download the newest version.


Any feedback that can help making this book better is highly appreciated. If you find errors, or if you have suggestions, please contact me.

Printed Version

If you prefer a printed version (paperback) rather than an ebook, you can get it here: http://www.lulu.com/shop/erika-heidi/vagrant-cookbook/paperback/product-21809746.html

Erika Heidi

As a Linux user since that time when you had to run startx to get any graphic experience, Erika Heidi started her carreer as SysAdmin, changing her focus to development after some years and embracing PHP as her main language - in 2003. Although development is her passion, she still likes the operational stuff, which turns to be a nice combination for devops.

  • Foreword

  • Preface

  • Acknowledgments

  • Introduction

    • What to expect from this book
    • Assumptions
  • Getting Started

    • How Vagrant Works
    • Terminology
    • Requirements
    • Installation
    • Updating Vagrant
    • Vagrant Commands
    • Your first Vagrant Up
  • The Vagrantfile

    • Basic Example
    • Defining the Box
    • Defining a Provisioner
    • Showing a post-up message (1.6+)
    • Setting up the Network
    • Setting up synchronized folders
    • VBoxManage Customizations
    • Quick Reference - Common Options
  • Provisioners

    • Overview
    • Getting Started with the Shell Provisioner
    • Automation Tools
    • Practical Example
  • Ansible

    • Overview
    • Quick Ansible Guide
    • Provisioning a PHP Web Server
  • Puppet

    • Overview
    • Quick Puppet Guide
    • Provisioning a PHP Web Server
  • Chef

    • Overview
    • Quick Chef Guide
    • Provisioning a PHP Web Server
  • Pro Tips

    • Update First!
    • NFS Performance Improvement
    • Permission Problems
    • Debugging
    • Login, Fix, Automate
    • VirtualBox Guest Additions
  • Advanced Topics

    • Running Multiple Virtual Machines
    • Provisioning VPSs on cloud services
    • Custom Boxes
  • Vagrant Share

    • Logging In
    • Sharing your Environment
    • Vagrant Connect
    • Securing your Shares
  • Recipes

    • System
    • Packages
    • Other
    • Conditional Execution
  • Appendix One: Vagrant Changelog

    • Vagrant 1.6
    • Vagrant 1.5