This commit is contained in:
James 2013-12-18 08:57:46 -08:00
commit 9415863724
3 changed files with 25 additions and 10 deletions

View file

@ -25,7 +25,14 @@ Vagrant.configure("2") do |config|
config.vm.box = 'your-box'
config.cache.auto_detect = true
# If you are using VirtualBox, you might want to enable NFS for shared folders
# config.cache.enable_nfs = true
# This is also very useful for vagrant-libvirt if you want bi-directional sync
# config.cache.enable_nfs = true
# You can now specify mount options if needed, eg:
# config.cache.mount_options = ['rw', 'vers=3', 'tcp', 'nolock']
# The nolock option can be useful for an NFSv3 client that wants to avoid the
# NLM sideband protocol. Without this option, apt-get might hang if it tries
# to lock files needed for /var/cache/* operations. All of this can be avoided
# by using NFSv4 everywhere. die NFSv3, die! The tcp option is not the default.
end
```

View file

@ -1,15 +1,16 @@
module VagrantPlugins
module Cachier
class Config < Vagrant.plugin(2, :config)
attr_accessor :scope, :auto_detect, :enable_nfs
attr_accessor :scope, :auto_detect, :enable_nfs, :mount_options
attr_reader :buckets
ALLOWED_SCOPES = %w( box machine )
def initialize
@scope = UNSET_VALUE
@auto_detect = UNSET_VALUE
@enable_nfs = UNSET_VALUE
@scope = UNSET_VALUE
@auto_detect = UNSET_VALUE
@enable_nfs = UNSET_VALUE
@mount_options = UNSET_VALUE
end
def enable(bucket, opts = {})
@ -31,10 +32,11 @@ module VagrantPlugins
def finalize!
return unless enabled?
@scope = :box if @scope == UNSET_VALUE
@auto_detect = false if @auto_detect == UNSET_VALUE
@enable_nfs = false if @enable_nfs == UNSET_VALUE
@buckets = @buckets ? @buckets.dup : {}
@scope = :box if @scope == UNSET_VALUE
@auto_detect = false if @auto_detect == UNSET_VALUE
@enable_nfs = false if @enable_nfs == UNSET_VALUE
@mount_options = false if @mount_options == UNSET_VALUE
@buckets = @buckets ? @buckets.dup : {}
end
def enabled?

View file

@ -18,7 +18,13 @@ module VagrantPlugins
FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist?
nfs_flag = env[:machine].config.cache.enable_nfs
env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', id: "vagrant-cache", nfs: nfs_flag
mount_options = env[:machine].config.cache.mount_options
if mount_options
env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', id: "vagrant-cache", nfs: nfs_flag, mount_options: mount_options
else
env[:machine].config.vm.synced_folder cache_root, '/tmp/vagrant-cache', id: "vagrant-cache", nfs: nfs_flag
end
env[:cache_dirs] = []