Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Vagrant Virtual Development Environment Cookbook

You're reading from   Vagrant Virtual Development Environment Cookbook 35 solutions to help you utilize virtualization with Vagrant more effectively – learn how to develop and manage Vagrant in the cloud to improve collaboration

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher
ISBN-13 9781784393748
Length 250 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Chad O Thompson Chad O Thompson
Author Profile Icon Chad O Thompson
Chad O Thompson
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Setting Up Your Environment FREE CHAPTER 2. Single Machine Environments 3. Provisioning a Vagrant Environment 4. Provisioning with Configuration Management Tools 5. Networked Vagrant Environments 6. Vagrant in the Cloud 7. Packaging Vagrant Boxes A. Vagrant Plugins B. A Puppet Development Environment C. Using Docker with Vagrant Index

Installing Vagrant and VirtualBox

Before we explore how to use Vagrant, we'll first need to install the software required to manage a virtual machine environment (a hypervisor) as well as the Vagrant software itself. In this recipe, we will install VirtualBox to use it with Vagrant. VirtualBox is an open source hypervisor that was initially the only hypervisor supported by Vagrant. As such, VirtualBox is broadly supported by the Vagrant community.

Getting ready

Before we install the VirtualBox and Vagrant software, we'll need to obtain its latest versions.

VirtualBox can be downloaded from the project website at http://virtualbox.org. You'll notice that while VirtualBox has a corporate sponsor (Oracle), the VirtualBox software is open source and freely available for use. VirtualBox is also supported on a wide variety of host platforms with a few limitations:

  • VirtualBox is supported only on Intel or AMD hardware. The Intel/AMD platform constitutes the vast majority of personal computing platforms in use today, but there are always exceptions. Make sure to check the VirtualBox manual for supported operating systems.
  • While the VirtualBox specifications note fairly minimal system requirements, keep in mind that your single workstation will be supporting two (or more) running operating systems at the same time. A rough guideline for system's RAM is to have minimal RAM to support your host operating system, plus the operating system requirements of the individual guests. This will vary depending on the guest operating system. For example, if you are running your Vagrant environments on a Windows machine with 8 GB of RAM, you'll want to limit your Vagrant machine to use 6 GB of RAM, leaving enough working memory for the host operating system. If the operating systems are using too much memory, you'll notice some significant performance issues as the host operating system begins paging to disk.

The packages downloaded from the VirtualBox site will be native to your particular operating system. Take particular care when downloading Linux packages; you'll want to ensure that the downloaded package is compatible with the operating system and system architecture. (Linux users might also find VirtualBox in repositories provided by your operating system provider. These packages are often outdated, but they may work with Vagrant. Be sure to check the minimum versions required in the Vagrant documentation.)

Vagrant packages are operating system-specific and can be downloaded from the Vagrant website at http://vagrantup.com. Download the version appropriate for your system.

Note

Warning

Vagrant was initially available for download through the use of RubyGems and is still available through gem install. This version, however, is significantly outdated and unable to support most of the features that will be covered in this book. Due to the complexity of managing Ruby dependencies, the Vagrant maintainers decided to ship Vagrant as a standalone package with an embedded Ruby interpreter to avoid possible conflicts. It's recommended that you use the package distributions from http://vagrantup.com, wherever possible.

How to do it...

Installing Vagrant and VirtualBox is similar to other software installation for your particular operating system. The project sites include detailed instructions to install Vagrant or VirtualBox on the software platform of your choice. We'll go through the installation of Vagrant and VirtualBox on OS X. There are versions available for Windows and a wide variety of Linux distributions. In any case, the installers, all roughly, follow the same procedure for the OS X installation demonstrated here.

Installing VirtualBox

  1. Download a copy of the installer from the VirtualBox website. In this example, we'll choose the version for OS X hosts.
    Installing VirtualBox
  2. Start the VirtualBox installer by opening the downloaded (OS X disk image) file. The disk image will include an installer along with documentation for VirtualBox and, if necessary, an uninstall tool. Double-click on the installer package to begin the VirtualBox installation.
    Installing VirtualBox

    Note

    The VirtualBox installation will require administrator permissions to both install the package and to modify system network settings. The installation of the VirtualBox hypervisor requires the installer to create a set of new network interfaces, which will allow network communications between the host and guest operating systems.

  3. Once the installation is complete, the installer will give you the option to open VirtualBox. A new installation of VirtualBox will display a welcome message in a window titled Oracle VM VirtualBox Manager. Once a few virtual machines are created, this dialog displays information about the machines created using VirtualBox (or the Vagrant VirtualBox provider).
    Installing VirtualBox

After the installation is completed and we are presented with the VirtualBox Manager dialog box, we can proceed with the installation of Vagrant itself.

Installing Vagrant

  1. Download a copy of the Vagrant installer from the Vagrant website (http://vagrantup.com). Select the appropriate version for your operating system. In this case, we will download the OS X universal installer that will download an installer that will work for both 32 and 64-bit machines. For the features discussed in this chapter (and for the majority of recipes in the book), you'll want to ensure that the Vagrant version is 1.5 or greater.
    Installing Vagrant
  2. The OS X download contains an installation package and an uninstall tool. Double-click on the installer to begin the installation. The Vagrant package installer is a native OS X package that will run the OS X software installer. Installing Vagrant will not be much different than installing other OS X software.
    Installing Vagrant
  3. The Vagrant installer will extract, copy files, and add the vagrant command to the executable path. On OS X, this will install Vagrant to the default OS X Applications/ directory. Vagrant is a command-line driven application, however, there are no programs accessed from the OS X Finder.
  4. Verify that Vagrant is working by opening a terminal window and executing the vagrant version command.
    Installing Vagrant

With both software packages installed successfully, we're ready to start using Vagrant!

Note

If you are a Ruby user or programmer, you might also note that a version of Vagrant is available via the Ruby gem package manager (gem install vagrant). When Vagrant 2.0 was released, the official distributions were released as packages with an embedded Ruby runtime. As such, the versions installed with the gem installer are outdated and will not work with most of the examples in this book.

How it works...

What we've done here is installed a working Vagrant environment that consists of:

  • A hypervisor application that can contain virtual machines
  • Vagrant, a tool that makes managing these machines simpler and available in code

It's important here to note that Vagrant is simply a framework to manage virtual machines, not an application to create and host virtual machines. When using a Vagrant environment, you'll often encounter errors that are not only related to Vagrant itself, but also related to the hypervisor application. For this reason, the choice of hypervisor becomes important when working with Vagrant. Many users can find tools that make VMware Desktop applications (Fusion and Workstation) simpler to troubleshoot when working with many virtual machines, whereas some will find it simpler to use external hypervisors (such as Amazon EC2 or DigitalOcean). Some experimentation might find the right workflow for you—keep in mind that Vagrant is a layer on top of many choices.

See also

You have been reading a chapter from
Vagrant Virtual Development Environment Cookbook
Published in: Feb 2015
Publisher:
ISBN-13: 9781784393748
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image