Book Image

Vagrant Virtual Development Environment Cookbook

Book Image

Vagrant Virtual Development Environment Cookbook

Overview of this book

Table of Contents (17 chapters)
Vagrant Virtual Development Environment Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Installing Vagrant providers


Vagrant and VirtualBox are a great environment to get started with. However, there might be instances where the use of other desktop hypervisors would be preferred, such as the VMware Desktop products (Fusion and Desktop). Recent versions of Vagrant (1.1 or higher) support VMware as a commercial addition. The VMware Fusion provider was the first commercial product released by HashiCorp and was quickly followed by VMware Desktop support. You can find more information about Vagrant and VMWare support at http://www.vagrantup.com/vmware.

Many users (including myself) immediately found the VMware provider to be tremendously useful for its improved speed and stability of the VMware platform. In this recipe, we'll look at installing the plugins for VMware Fusion, keeping in mind that the VMware Desktop products and the Vagrant provider for the VMware Desktop are commercial products. You'll need to have on hand a VMware Desktop license for your platform and need to purchase the Vagrant provider for VMware from HashiCorp. In this example, we'll look at the installation of the provider, but keep in mind that all the examples in this book should also work with the freely available VirtualBox or Vagrant environment.

Getting ready

Before we can start with this example, we'll have to assume that you have purchased and installed the VMware Desktop product for your platform: Fusion for OS X, Workstation for Windows or Linux. These products can be purchased from a number of retailers or directly from VMware (http://www.vmware.com).

With VMware installed, we'll have to obtain a copy of the Vagrant provider directly from HashiCorp. At the time of writing this book, the plugin is not available through third parties. You can purchase the VMware plugin at http://vagrantup.com/vmware.

Once you have paid for the plugin, HashiCorp will send an e-mail with the download instructions and some basic instructions on how to install the provider. We'll walk through this installation in this recipe.

How to do it...

Vagrant providers rely on Vagrant's plugin capability—the ability to extend Vagrant through the Ruby environment. To install the plugin, open a command-line environment and execute Vagrant with the plugin command.

In this example, we'll install the VMware Fusion plugin, although the plugin installation will be similar for any number of providers. (See https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins for a relatively up-to-date listing of maintained plugins.)

  1. Install the VMware Fusion plugin with the vagrant plugin install vagrant-vmware-fusion command.

    This will download the plugin and add the code to your local Vagrant installation. With many plugins, this will be the final step—installation itself is pretty straightforward. In this case, however, we'll need to install the license for the plugin.

  2. Install the plugin license using the plugin license command from the directory where the license file was placed:

    vagrant plugin license vagrant-vmware-fusion-license.lic
    

    This will install the plugin license and ready the plugin for use.

  3. Verify the plugin installation with:

    vagrant plugin list
    

    A list of currently installed plugins is returned, including some that are packaged with the distribution, these are marked system.

  4. Start a VMware environment by initializing a new environment. This will be identical to the steps in the prior recipe.

  5. With a terminal window open and the command executing in a directory of your choice, execute the vagrant init puppetlabs/ubuntu-14.04-32-nocm command

    This will create a new Vagrantfile that is identical to the previous example. This time, we'll start the environment with the provider option:

    vagrant up –provider=vmware_fusion
    

    A boot sequence will be presented with the difference to the prior example being that a new environment (box file) will be downloaded and booted. This new machine will use the VMware Fusion hypervisor to manage the Vagrant virtual machine.

How it works...

This example installed a new bit of functionality within Vagrant; the expanded functionality of plugins allows Vagrant to manage different virtual environments with an identical API. In general, Vagrant plugins can be used to extend Vagrant in a number of different ways—providers are

You might have noticed that the only difference in starting the Vagrant environment from the previous recipe was the use of the provider option when starting the machine. If you want to ensure that a virtual machine always uses a specific provider when starting, set the VAGRANT_DEFAULT_PROVIDER=vmware_fusion environment variable.

Setting an environment variable depends on your system and terminal shell in a Unix- based system (OS X, Linux); you might set this variable in your login shell profile (either .bash_profile or .bashrc), and for Microsoft Windows, this variable is set in the Environment Variables... dialog. Consult the documentation for your platform on how to create system variables.

With a VMware Desktop plugin installed, you can use VMware to manage virtual environments, whereas with other plugins, we can also use Vagrant to manage virtual machines locally with other hypervisors (for example, Parallels on OS X) or even in remote hypervisors (for example, VMware ESXi environments, Amazon Web Services). We'll see examples on how to use Vagrant in these environments in later recipes in the book.

See also

  • VMware: http://vmware.com. VMware provides a wide variety of hypervisor platforms from the desktop platforms used in this book to hypervisor infrastructures for data center management.

  • A list of currently available Vagrant plugins: https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins. The Vagrant project keeps a list of plugins that are available to extend the functionality of Vagrant. The VMware providers are only one example of a wide variety of plugins available.