Vagrant
Configuration
While Vagrant VMware Desktop provider is a drop-in replacement for VirtualBox, there are some additional features that are exposed that allow you to more finely configure VMware-specific aspects of your machines.
Configuration settings for the provider are set in the Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "my-box"
config.vm.provider "vmware_desktop" do |v|
v.gui = true
end
end
Provider settings
allowlist_verified
(bool, symbol) - Flag that VMware box has been properly configured for allow list VMX settings.true
if verified,false
if unverified,:disable_warning
to silence allowlist warnings.base_address
(string) - Address to be reserved from the DHCP server. This option requires thebase_mac
option to be set as well.base_mac
(string) - Custom MAC address to be used for the default NAT interface deviceclone_directory
(string) - Path for storing VMware clones. This value can also be set using theVAGRANT_VMWARE_CLONE_DIRECTORY
environment variable. This defaults to./.vagrant
enable_vmrun_ip_lookup
(bool) - Use vmrun to discover guest IP address. This defaults totrue
functional_hgfs
(bool) - HGFS is functional within the guest. This defaults to detected capability of the guestgui
(bool) - Launch guest with a GUI. This defaults tofalse
linked_clone
(bool) - Use linked clones instead of full copy clones. This defaults totrue
if linked clones are functional based on VMware installation.nat_device
(string) - The host vmnet device to use for the default NAT interface. By default this will be automatically detected with a fallback tovmnet8
.port_forward_network_pause
- Number of seconds to pause after applying port forwarding configuration. This allows guest time to acquire DHCP address if previous address is dropped when VMware network services are restarted. This defaults to0
ssh_info_public
(bool) - Use the public IP address for SSH connections to guest. This defaults tofalse
unmount_default_hgfs
(bool) - Unmount the default HGFS mount point within the guest. This defaults tofalse
utility_port
(integer) - Listen port of the Vagrant VMware Utility service. This defaults to9922
utility_certificate_path
(string) - Path to the Vagrant VMware Utility service certificates directory. The default value is dependent on the hostverify_vmnet
(bool) - Verify vmnet devices health before usage. This defaults totrue
vmx
(hash) - VMX key/value pairs to set or unset. If the value isnil
, the key will be deleted.
VM Clone Directory
By default, the VMware provider will clone the VMware VM in the box to the ".vagrant" folder relative to the folder where the Vagrantfile is. Usually, this is fine. For some people, for example those who use a differential backup software such as Time Machine, this is very annoying because you cannot regularly ignore giant virtual machines as part of backups.
The directory where the provider clones the virtual machine can be
customized by setting the VAGRANT_VMWARE_CLONE_DIRECTORY
environmental
variable. This does not need to be unique per project. Each project will
get a different sub-directory within this folder. Therefore, it is safe to
set this systemwide.
Linked Clones
By default new machines are created using a linked clone to the base box. This reduces the time and required disk space incurred by directly importing the base box.
Linked clones are based on a master VM, which is generated by importing the base box only once the first time it is required. For the linked clones only differencing disk images are created where the parent disk image belongs to the master VM. To disable linked clones:
config.vm.provider "vmware_desktop" do |v|
v.linked_clone = false
end
VMX Customization
If you want to add or remove specific keys from the VMX file, you can do that:
config.vm.provider "vmware_desktop" do |v|
v.vmx["custom-key"] = "value"
v.vmx["another-key"] = nil
end
In the example above, the "custom-key" key will be set to "value" and the "another-key" key will be removed from the VMX file.
VMX customization is done as the final step before the VMware machine is booted, so you have the ability to possibly undo or misconfigure things that Vagrant has set up itself.
VMX is an undocumented format and there is no official reference for the available keys and values. This customization option is exposed for people who have knowledge of exactly what they want.
The most common keys people look for are setting memory and CPUs. The example below sets both:
config.vm.provider "vmware_desktop" do |v|
v.vmx["memsize"] = "1024"
v.vmx["numvcpus"] = "2"
end