This is part 1 of my series on Ansible provisioning for Vagrant running VMware.
In this post I will describe how things are supposed to work first time right when you run a VMware virtual machine using Vagrant. If you are interested in what could go wrong, or if you encounter errors yourself, you are advised to read [todo: I will follow up with a post on what went wrong].
Please note that Vagrant is most widely used with VirtualBox. If you are using Vagrant with VirtualBox and you are happy with that, there is no reason why you should try VMware.
The plugin: vagrant-vmware-fusion
While Vagrant works with VirtualBox by default, you need a plugin for it to work with VMware. There are two VMware providers available, one for VMware Fusion (used on the Mac) and one for WMware Workstation (used on Windows and Linux). The provider plugin that I will be using is called vagrant-vmware-fusion.
VMware and the vagrant-vmware-fusion plugin both are not free, unlike VirtualBox.
My software environment
If you made it till here you might be interested in actually following along, so I might as well tell you what software I am using: I’m on Mac OS X Mavericks (version 10.9.2). My Vagrant is at 1.5.4 and my vagrant-vmware-fusion plugin is version 2.4.0. My VMware Fusion installation is at version 6.0.3.
In case you haven’t got Vagrant installed, you must install it using the packaged installer, which you can find here: http://www.vagrantup.com/downloads.html
VMware Fusion can be downloaded here: http://www.vmware.com/products/fusion/
The vagrant-vmware-fusion plugin can be purchased here (there is no trial version): http://www.vagrantup.com/vmware
Installation
The software installations are straightforward, except for the plugin. It is done on the command line, after you have installed both Vagrant and VMware Fusion. Make sure you have the vagrant command by typing
vagrant --version
In my case, this outputs:
Vagrant 1.5.4
Because there is no trial version of the plugin, you have to purchase a license before you can continue. Although there is no trial period, purchasing the license is risk-free. Should you not be satisfied with your purchase, a single e-mail to its vendors will suffice to get your money back and have the license revoked.
All you will download after purchasing the license is a license file. Next, you may proceed installing the plugin by following the installation instructions. Make sure that you keep the license file somewhere and make notes of it.
To verify if the plugin is installed, type:
vagrant plugin list
In my case that yields:
vagrant-login (1.0.1, system) vagrant-share (1.0.1, system) vagrant-vmware-fusion (2.4.0)
Adding and starting your VM
Now that you are all set, you will need a virtual machine to bring up using the famous vagrant up command. The good news is you can download a base box from the vagrant website: I downloaded the Ubuntu precise64 VMware box base box for vmware.
Place the base box somewhere on your file system and cd into that directory on the command line. Your next step is to add the box to Vagrant:
vagrant box add --name=precise64_vmware --provider=vmware_fusion ./precise64_vmware.box
This should give you the following output (except for the directory where you have placed the base box):
==> box: Adding box 'precise64_vmware' (v0) for provider: vmware_fusion box: Downloading: file:///Users/bartmcleod/vagrant-vmware-fusion/blog/precise64_vmware.box ==> box: Successfully added box 'precise64_vmware' (v0) for 'vmware_fusion'!
And then:
vagrant init
[Edit: July 12, 2014] I received feedback from Jim Preston, that as of Vagrant 1.6.8 you need to include the box name with the init command, like so:
vagrant init precise64_vmware
I haven’t yet tried this myself, but I thought it would be wise to include it here, since otherwise you might get stuck on this bit.[/Edit]
[Edit: July 20, 2014]I installed Vagrant 1.6.3 and verified whether the name of the box was needed with the init command and in my case it wasn’t needed.[/Edit]
Which results in:
A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.
And finally:
vagrant up --provider=vmware_fusion
Do not forget the –provider flag. You may omit it later, but the first time you bring up your box, you need it. The above command will yield the following output if everything went ok:
Bringing machine 'default' up with 'vmware_fusion' provider... ==> default: Cloning VMware VM: 'base'. This can take some time... ==> default: Verifying vmnet devices are healthy... ==> default: Preparing network adapters... ==> default: Starting the VMware VM... ==> default: Waiting for the VM to finish booting... ==> default: The machine is booted and ready! ==> default: Forwarding ports... default: -- 22 => 2222 ==> default: Configuring network adapters within the VM... ==> default: Waiting for HGFS kernel module to load... ==> default: Enabling and configuring shared folders... default: -- /Users/bartmcleod/vagrant-vmware-fusion/blog: /vagrant
When you’re done:
vagrant halt
That’s it! Now you know how to use Vagrant and VMware together. If you would like to know how to provision your new box using Ansible, then please read my next post [todo].
excellent write up.
I hit a wall and get beyond
$ vagrant box add –name=precise64_vmware –provider=vmware_fusion ./precise64_vmware.bo
this error comes up:
The plugins failed to load properly. The error message given is
shown below.
uninitialized constant Rails
have you come across this error?
No, I don’t remember seeing that error. Can you provide some context? What is your Vagrant version and your host OS?
I got sorted. I had remove the login plugin
Thanks Bart.
My versions are:
OS X
ProductName: Mac OS X
ProductVersion: 10.9.5
BuildVersion: 13F34
Vagrant
1.7.2
Fusion
Version 7.1.0 (2314774)
plugins:
login (0.1.0) [I took this out]
vagrant-share (1.1.3, system)
vagrant-vmware-fusion (3.2.0)
have you had time to write up the ansible part?