Published on 12 June 2013 by

Developers need a quick, reproducible method for creating environments to run and test their applications. Vagrant addresses this need by making it easy to create and control virtual machines.

Until recently, the only virtualization provider for Vagrant was for VirtualBox. That changed this spring when Vagrant creator Mitchell Hashimoto released a VMware provider for Vagrant. Now you can use Vagrant to create and control VMware virtual machines using VMware Workstation and VMware Fusion along with VirtualBox.

How Vagrant Works

Following the "configuration as code" pattern, Vagrant allows you to specify a "base box"—a "box" is just a VM with a few special configuration conventions—and a configuration file to further customize the settings of the virtual machine. If your needs are pretty standard, you can have a Vagrant box up and running in a few minutes. If you need to provision and/or configure the virtual machine further, Vagrant can use Puppet manifests to get exactly the environment you require.

VMware Boxes Provide Performance and Stability

It's no secret that VMware has spent a lot of time optimizing for performance, and this work shows when running VMware boxes under Vagrant. Subjectively, Vagrant tasks seem snappier. Some quick and dirty testing using VMware Fusion boxes on a Late 2011 Macbook Pro with 8GB RAM confirms this. Creating and provisioning a three-box set from base boxes was about 20 percent faster than using the VirtualBox provider. Bringing those three boxes up from a suspended state was about 35 percent faster.

The stability of Vagrant VMware boxes is impressive. In a couple of weeks of testing I've not seen a single hiccup. In my testing, the VMware boxes have run perfectly for up to weeks at a time.

Installing the Vagrant VMware provider

First, you'll need either VMWare Fusion 5.x or higher (Mac OS X); or VMware Workstation 9.x or higher (Windows or Linux). You'll also need Vagrant 1.1 or higher, but grab the latest as Mitchell has been hard at work on both Vagrant and the VMware provider. Once those are installed, you can purchase your VMware provider license on the Vagrant website. With that license in hand, install and license the Vagrant plugin.

For Fusion users:

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

For Workstation users:

vagrant plugin install vagrant-vmware-workstation
vagrant plugin license vagrant-vmware-workstation license.lic

Now that the VMware provider plugin is installed, setting up the boxes and provisioning is pretty much the same as using VirtualBox, with a few differences:

You'll need a base box set up to use the VMware provider rather than VirtualBox. Since the VMware provider is pretty new, there are only a few compatible base boxes. There are some listed on Vagrantbox.es and at least one compatible template on the veewee repo should you wish to build your own base box. I'm sure that the paucity of VMware compatible base boxes will remedied soon.

Configuring Vagrant-Managed Virtual Machines

Some of the configuration has changed, for instance, using Vagrant version 1.0.x and VirtualBox, you would set the memory of the VM like this:

config.vm.customize ["modifyvm", :id, "--memory", "2048"]

In Vagrant with VMware Fusion, you achieve the same with this:

config.vm.provider :vmware_fusion do |v|
  v.vmx["memsize"] = "2048"
end

With VMware Workstation:

config.vm.provider :vmware_workstation do |v|
  v.vmx["memsize"] = "2048"
end

You can include overrides for specific providers. For instance, to specify a different base box:

Vagrant.configure("2") do |config|
  [...]
  config.vm.define :node1 do |node1_config|
    node1_config.vm.provider :vmware_fusion do |vmware, override|
      override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"
    end
    node1_config.vm.provider :virtualbox do |virtualbox, override|
      override.vm.box_url = "http://files.vagrantup.com/precise64.box"
    end
  end
  [...]
end

The Vagrant VMware Configuration page has information on some of the settings. There is no official public reference for VMX settings, so information about them is spread out, but this Vagrant Google Groups message has some discussion.

Since boxes are provider-specific now, you may need to specify the provider the first time you bring up a box (and the box is created):

vagrant up  --provider vmware_workstation

Learn More

Share via:
Tagged:

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.