Using a disposable CentOS 7.x with VMware in seconds
Vagrant supports both VMware Workstation and VMware Fusion through official plugins available on the Vagrant store (https://www.vagrantup.com/vmware). Follow the indications from the official website to install the plugins.
Vagrant boxes depend on the hypervisor—a VirtualBox image won't run on VMware. You need to use dedicated images for each supervisor you choose to use. For example, Ubuntu official releases only provide VirtualBox images. If you try to create a Vagrant box with a provider while using an image built for another provider, you'll get an error.
Getting ready
To step through this recipe, you will need the following:
- A working Vagrant installation
- A working VMware Workstation (PC) or Fusion (Mac) installation
- A working Vagrant VMware plugin installation
- An Internet connection
How to do it…
The Chef Bento project provides various multiprovider images we can use. For example, let's use a CentOS 7.2 with Vagrant (bento/centos-7.2) with this simplest Vagrantfile:
Vagrant.configure("2") do |config| config.vm.box = "bento/centos-7.2" end
Start your CentOS 7.2 virtual environment and specify the hypervisor you want to run:
$ vagrant up --provider=vmware_fusion $ vagrant ssh
You're now running a CentOS 7.2 Vagrant box using VMware!
How it works…
Vagrant is powered by plugins extending its usage and capabilities. In this case, the Vagrant plugin for VMware delegates all the virtualization features to the VMware installation, removing the need for VirtualBox.
There's more…
If VMware is your primary hypervisor, you'll soon be tired to always specify the provider in the command line. By setting the VAGRANT_DEFAULT_PROVIDER
environment variable to the corresponding plugin, you will never have to specify the provider again, VMware will be the default:
$ export VAGRANT_DEFAULT_PROVIDER=vmware_fusion $ vagrant up
See also
- The Chef Bento Project at http://chef.github.io/bento/
- A community VMware vSphere plugin at https://github.com/nsidc/vagrant-vsphere
- A community VMware vCloud Director plugin at https://github.com/frapposelli/vagrant-vcloud
- A community VMware vCenter plugin at https://github.com/frapposelli/vagrant-vcenter
- A community VMware vCloud Air plugin at https://github.com/frapposelli/vagrant-vcloudair