vagrantvagrantfile

Vagrantfile: Disabling synced folders for one provider, but not another


I have been using Vagrant with VirtualBox for local development. Now, I want to deploy to Azure (question would be same with AWS).

When working locally with VirtualBox, it's awesome to have the synced folder. But I definitely don't want a synced folder for the cloud VM. So, how can I have it enabled for the former but disabled for the latter?

A snippet of my vagrantfile is below; however this doesn't seem to have any effect. Appreciate any pointers.

Vagrant.configure('2') do |config|
  config.vm.synced_folder ".", "/vagrant"
  # …

  config.vm.provider :azure do |azure, override|
    override.vm.synced_folder ".", "/vagrant", disabled: true
    # …
  End
  # …
end

I've also tried initially disabling the synced folder, and then enabling it only for VirtualBox - but Azure still prompts for username/password and attempts to create an SMB share.

Update: Even if I disable it in the main section, and don't touch it for Azure, it still tries to create a SMB share, and complains that it can't find my machine (my laptop is behind NAT).


Solution

  • It turns out that the default synced folder was indeed being disabled correctly.

    However, the Chef provisioner was being used, and behind the scenes this also uses synced folders! The solution therefore is to use a Chef server, or as I chose - to do everything via a shell provisioner.

    Hope this question helps someone encountering this problem in the future.