Vagrant: Up and Running

Book description

Discover why Vagrant is a must-have tool for thousands of developers and ops engineers. This hands-on guide shows you how to use this open source software to build a virtual machine for any purpose—including a completely sandboxed, fully provisioned development environment right on your desktop.

Vagrant creator Mitchell Hashimoto shows you how to share a virtual machine image with members of your team, set up a separate virtualization for each project, and package virtual machines for use by others. This book covers the V1 (1.0.x) configuration syntax running on top of a V2 (1.1+) core, the most stable configuration format running on the latest core.

  • Build a simple virtual machine with just two commands and no configuration
  • Create a development environment that closely resembles production
  • Automate software installation and management with shell scripts, Chef, or Puppet
  • Set up a network interface to access your virtual machine from any computer
  • Use your own editor and browser to develop and test your applications
  • Test complicated multi-machine clusters with a single Vagrantfile
  • Change Vagrant’s default operating system to match your production OS
  • Extend Vagrant features with plugins, including components you build yourself

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. Safari® Books Online
    4. How to Contact Us
    5. Content Updates
      1. October 29, 2013
    6. Acknowledgments
  3. 1. An Introduction to Vagrant
    1. Why Vagrant?
    2. The Tao of Vagrant
    3. Alternatives to Vagrant
      1. Plain Desktop Virtualization
      2. Containers
      3. Cloud
    4. Vagrant Versions
    5. Setting Up Vagrant
      1. Installing VirtualBox
      2. Installing Vagrant
        1. Mac OS X
        2. Windows
        3. Linux
      3. Common Mistakes
        1. Improper PATH Configuration
        2. Conflicting RubyGems Installation
    6. Using Vagrant Without VirtualBox
    7. Help!
  4. 2. Your First Vagrant Machine
    1. Up and Running
    2. The Vagrantfile
      1. V1 versus V2 Configuration
    3. Boxes
    4. Up
    5. Working with the Vagrant Machine
      1. State of the Vagrant Machine
      2. SSH
      3. Shared Filesystem
      4. Basic Networking
      5. Teardown
        1. Suspend
        2. Halt
        3. Destroy
    6. What’s Next?
  5. 3. Provisioning Your Vagrant VM
    1. Why Automated Provisioning?
    2. Supported Provisioners
    3. Manually Setting Up Apache
    4. Automated Provisioner Basics
      1. Shell Scripts
      2. Chef
      3. Puppet
    5. Multiple Provisioners
    6. “No Provision” Mode
    7. In-Depth Provisioner Usage
      1. Shell Scripts
        1. Inline scripts
        2. Run-once scripts
      2. Chef Server
      3. Puppet
        1. Modules
        2. Hiera Data
        3. Custom Facts
        4. Using a Puppet Master
    8. What’s Next?
  6. 4. Networking in Vagrant
    1. Forwarded Ports
      1. Pros and Cons
      2. Basic Usage
      3. Collision Detection and Correction
      4. TCP versus UDP
    2. Host-Only Networking
      1. Pros and Cons
      2. Basic Usage
      3. Guest Operating System Dependency
    3. Bridged Networking
      1. Pros and Cons
      2. Basic Usage
    4. Composing Networking Options
    5. NAT Requirement As the First Network Interface
    6. What’s Next?
  7. 5. Modeling Multimachine Clusters
    1. Running Multiple Virtual Machines
    2. Controlling Multiple Machines
    3. Communication Between Machines
      1. Host-Only Networks
      2. Bridged Networks
    4. Real Example: MySQL
    5. What’s Next?
  8. 6. Boxes
    1. Why Boxes?
    2. Box Format
    3. Basic Box Management with Vagrant
    4. Creating New Boxes from an Existing Environment
    5. Creating New Boxes from Scratch
      1. Creating the VirtualBox Machine
      2. Configuring the Operating System
      3. Installing VirtualBox Guest Additions
      4. Additional Software
      5. Minimizing the Final Box Size
      6. Packaging It Up
      7. Setting Vagrantfile Defaults
    6. What’s Next?
  9. 7. Extending Vagrant with Plug-Ins
    1. Extensible Features
    2. Managing Vagrant Plug-Ins
    3. Plug-In Development Basics
      1. Plug-In Definition
      2. Plug-In Components
      3. Error Handling
      4. Vagrant Internals
    4. A Basic Plug-In Development Environment
    5. Developing a Custom Command
      1. Component
      2. Implementation
      3. Working with the Virtual Machine
      4. Working with Multimachine Environments
      5. Parsing Command-Line Options
    6. Adding New Configuration Options
      1. Component
      2. Implementation
      3. Accessing the Configuration
      4. Configuration Merging
      5. Validation
    7. Adding a Custom Provisioner
      1. Component
      2. Implementation
      3. Provisioner Configuration
      4. Configuring the Machine
    8. Modifying Existing Vagrant Behavior
      1. Component
      2. Implementation
      3. Useful Keys in the Action Environment
      4. Learning More
    9. Other Plug-In Components
    10. Packaging the Plug-In
  10. A. Vagrant Environmental Variables
    1. VAGRANT_CWD
    2. VAGRANT_HOME
    3. VAGRANT_LOG
    4. VAGRANT_NO_PLUGINS
    5. VAGRANT_VAGRANTFILE
  11. B. Vagrant Configuration Reference
  12. C. Troubleshooting and Debugging
    1. IRC
    2. Mailing List/Google Group
    3. Professional Support
  13. Index
  14. About the Author
  15. Colophon
  16. Copyright

Product information

  • Title: Vagrant: Up and Running
  • Author(s): Mitchell Hashimoto
  • Release date: June 2013
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449335830