Add mount_options option.
This option can be very useful with the existing enable_nfs option to choose a different protocol like tcp (udp is the default), and to add other nfs options like nolock.
This commit is contained in:
parent
1862eeca61
commit
7a4312ac80
3 changed files with 25 additions and 10 deletions
|
@ -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
|
||||
# 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
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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 )
|
||||
|
@ -10,6 +10,7 @@ module VagrantPlugins
|
|||
@scope = UNSET_VALUE
|
||||
@auto_detect = UNSET_VALUE
|
||||
@enable_nfs = UNSET_VALUE
|
||||
@mount_options = UNSET_VALUE
|
||||
end
|
||||
|
||||
def enable(bucket, opts = {})
|
||||
|
@ -34,6 +35,7 @@ module VagrantPlugins
|
|||
@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
|
||||
|
||||
|
|
|
@ -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
|
||||
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] = []
|
||||
|
||||
|
|
Loading…
Reference in a new issue