Advanced Vagrantfile Configuration

• Updated May 13, 2017


Vagrantfile’s are written in Ruby, so you have the full power of Ruby at your fingertips when creating a Vagrantfile.

This post will be an ever growing list of advanced Vagrantfile configurations.

Any changes made to a Vagrantfile can be applied to a running Vagrant Box by running vagrant reload $BOX.

Disable Shared Folders

config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true

Change the Number of CPUs Allocated

VirtualBox Provider

config.vm.provider "virtualbox" do |v|
  v.customize ["modifyvm", :id, "--cpus", "2"]
end

VMware Fusion Provider

config.vm.provider "vmware_fusion" do |v|
  v.vmx["numvcpus"] = "2"
end

Change the Amount of Memory Allocated

VirtualBox Provider

config.vm.provider "virtualbox" do |v|
  v.customize ["modifyvm", :id, "--memory", "2048"]
end

VMware Fusion Provider

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

Add a Host Only Unconfigured NIC

VirtualBox Provider

config.vm.provider "virtualbox" do |v|
  v.customize ["modifyvm", :id, "--nic2", "intnet"]
end

VMware Fusion Provider

config.vm.provider "vmware_fusion" do |v|
  v.vmx["ethernet1.present"] = "TRUE"
  v.vmx["ethernet1.connectionType"] = "hostonly"
  v.vmx["ethernet1.addressType"] = "generated"
  v.vmx["ethernet1.virtualDev"] = "e1000"
end

If you found this post useful and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided links.

The following links are part of affiliate programs, and I will receive a referral payment from any of the services you sign-up for.

  • Get Faster Shipping: About to order some stuff on Amazon but want to get more value out of the money you would normally pay for shipping? Sign-up for a free, 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.
  • Start Investing Now: Looking to start investing some of your saved income? Get started by opening an account with Webull, where upon sign-up and opening a brokerage account with an initial deposit of $100 or more you will receive free stock(s). The promotions are always changing, so be sure to click the link to see the latest.

Thanks for reading and take care.