The folder where I have Vagrantfile is being auto-generated during the build, so it gets cleaned up, but I'd like to still be able to use the created machines. The easiest way would be to put .vagrant folder somewhere outside the auto-generated folder. Is this possible?
Vagrantfile in your Vagrant home directory (defaults to ~/. vagrant. d ). This lets you specify some defaults for your system user.
Vagrant automatically syncs files to and from the guest machine. This way you can edit files locally and run them in your virtual development environment. By default, Vagrant shares your project directory (the one containing the Vagrantfile) to the /vagrant directory in your guest machine.
Windows: C:/Users/USERNAME/. vagrant.
You have (at least) two options:
Use VAGRANT_DOTFILE_PATH
to set the the location where the project specific data is stored (defaults to .vagrant
as you already know). Note that the path has to be project/Vagrantfile specific.
cd
to a directory where you want the .vagrant
directory to be created, and use VAGRANT_VAGRANTFILE
to specify the path to the generated Vagrantfile.
I know this is an old question, but for anyone arriving here via Google, there is a workaround if you really want to specify the metadata directory without mucking about with environment variables each time. Just put this in the top of your Vagrantfile:
VAGRANT_DOTFILE_PATH = 'custom/dotfile/path'
if(ENV['VAGRANT_DOTFILE_PATH'].nil? && '.vagrant' != VAGRANT_DOTFILE_PATH)
puts 'changing metadata directory to ' + VAGRANT_DOTFILE_PATH
ENV['VAGRANT_DOTFILE_PATH'] = VAGRANT_DOTFILE_PATH
puts 'removing default metadata directory ' + FileUtils.rm_r('.vagrant').join("\n")
system 'vagrant ' + ARGV.join(' ')
ENV['VAGRANT_DOTFILE_PATH'] = nil #for good measure
abort 'Finished'
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With