Skip to content

Instantly share code, notes, and snippets.

@LogicalChaos
Created January 8, 2015 20:23
Show Gist options
  • Save LogicalChaos/4e7a0fc331358370c3d1 to your computer and use it in GitHub Desktop.
Save LogicalChaos/4e7a0fc331358370c3d1 to your computer and use it in GitHub Desktop.
Add to ~/.vagrant.d directory to put vagrant meta directories (hence VM) in a common directory based on the current directory name.
# -*- mode: ruby -*-
# vi: set ft=ruby :
if !ARGV.find { |arg| /global/ =~ arg } and !ENV['VAGRANT_DOTFILE_PATH'] and File.exists?('.vagrant.keep')
if !ENV['VAGRANT_COMMON_DIRECTORY_ROOT']
abort '.vagrant.keep file is present but VAGRANT_COMMON_DIRECTORY_ROOT is not set'
end
pn = Pathname::pwd
ENV['VAGRANT_DOTFILE_PATH'] = "#{ENV['VAGRANT_COMMON_DIRECTORY_ROOT']}/#{pn.basename}"
puts 'metadata directory: ' + ENV['VAGRANT_DOTFILE_PATH']
if File.directory?('.vagrant')
#puts 'removing .vagrant directory'
FileUtils.rm_r('.vagrant') if File.directory?('.vagrant')
end
system 'vagrant ' + ARGV.join(' ')
abort
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment