core: Arbitrary NFS options with nfs_options [GH-1029]
This commit is contained in:
parent
4329c9f06d
commit
3a14d27f90
|
@ -28,6 +28,8 @@ FEATURES:
|
||||||
the VM if a fatal error occurs. [GH-2011]
|
the VM if a fatal error occurs. [GH-2011]
|
||||||
- NFS: Arbitrary mount options can be specified using the
|
- NFS: Arbitrary mount options can be specified using the
|
||||||
`mount_options` option on synced folders. [GH-1029]
|
`mount_options` option on synced folders. [GH-1029]
|
||||||
|
- NFS: Arbitrary export options can be specified using
|
||||||
|
`bsd__nfs_options` and `linux__nfs_options`. [GH-1029]
|
||||||
|
|
||||||
IMPROVEMENTS:
|
IMPROVEMENTS:
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,29 @@ module VagrantPlugins
|
||||||
dirs.sort_by! { |d| d.length }
|
dirs.sort_by! { |d| d.length }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Setup the NFS options
|
||||||
|
dirmap.each do |dirs, opts|
|
||||||
|
if !opts[:bsd__nfs_options]
|
||||||
|
opts[:bsd__nfs_options] = ["alldirs"]
|
||||||
|
end
|
||||||
|
|
||||||
|
hasmapall = false
|
||||||
|
opts[:bsd__nfs_options].each do |opt|
|
||||||
|
if opt =~ /^mapall=/
|
||||||
|
hasmapall = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !hasmapall
|
||||||
|
opts[:bsd__nfs_options] << "mapall=#{opts[:map_uid]}:#{opts[:map_gid]}"
|
||||||
|
end
|
||||||
|
|
||||||
|
opts[:bsd__compiled_nfs_options] = opts[:bsd__nfs_options].map do |opt|
|
||||||
|
"-#{opt}"
|
||||||
|
end.join(" ")
|
||||||
|
end
|
||||||
|
|
||||||
@logger.info("Exporting the following for NFS...")
|
@logger.info("Exporting the following for NFS...")
|
||||||
dirmap.each do |dirs, opts|
|
dirmap.each do |dirs, opts|
|
||||||
@logger.info("NFS DIR: #{dirs.inspect}")
|
@logger.info("NFS DIR: #{dirs.inspect}")
|
||||||
|
|
|
@ -35,6 +35,25 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def nfs_export(id, ips, folders)
|
def nfs_export(id, ips, folders)
|
||||||
|
folders.each do |k, opts|
|
||||||
|
if !opts[:linux__nfs_options]
|
||||||
|
opts[:linux__nfs_options] ||= ["rw", "no_subtree", "check", "all_squash"]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Only automatically set anonuid/anongid if they weren't
|
||||||
|
# explicitly set by the user.
|
||||||
|
hasgid = false
|
||||||
|
hasuid = false
|
||||||
|
opts[:linux__nfs_options].each do |opt|
|
||||||
|
hasgid = !!(opt =~ /^anongid=/) if !hasgid
|
||||||
|
hasuid = !!(opt =~ /^anonuid=/) if !hasuid
|
||||||
|
end
|
||||||
|
|
||||||
|
opts[:linux__nfs_options] << "anonuid=#{opts[:map_uid]}" if !hasuid
|
||||||
|
opts[:linux__nfs_options] << "anongid=#{opts[:map_gid]}" if !hasgid
|
||||||
|
opts[:linux__nfs_options] << "fsid=#{opts[:uuid]}"
|
||||||
|
end
|
||||||
|
|
||||||
output = TemplateRenderer.render('nfs/exports_linux',
|
output = TemplateRenderer.render('nfs/exports_linux',
|
||||||
:uuid => id,
|
:uuid => id,
|
||||||
:ip => ip,
|
:ip => ip,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
||||||
<% folders.each do |dirs, opts| %>
|
<% folders.each do |dirs, opts| %>
|
||||||
<%= dirs.map { |d| "\"#{d}\"" }.join(" ") %> <%= ips.join(" ") %><% if opts[:map_uid] -%> -mapall=<%= [opts[:map_uid],opts[:map_gid]].compact.join(":") %><% end -%>
|
<%= dirs.map { |d| "\"#{d}\"" }.join(" ") %> <%= ips.join(" ") %> <%=opts[:bsd__compiled_nfs_options] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
# VAGRANT-END: <%= user %> <%= uuid %>
|
# VAGRANT-END: <%= user %> <%= uuid %>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
||||||
<% folders.each do |dirs, opts| %>
|
<% folders.each do |dirs, opts| %>
|
||||||
<%= dirs.map { |d| "\"#{d}\"" }.join(" ") %> <%= ips.join(" ") %><% if opts[:map_uid] -%> -alldirs -mapall=<%= [opts[:map_uid],opts[:map_gid]].compact.join(":") %><% end -%>
|
<%= dirs.map { |d| "\"#{d}\"" }.join(" ") %> <%= ips.join(" ") %> <%=opts[:bsd__compiled_nfs_options] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
# VAGRANT-END: <%= user %> <%= uuid %>
|
# VAGRANT-END: <%= user %> <%= uuid %>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
||||||
<% ips.each do |ip| %>
|
<% ips.each do |ip| %>
|
||||||
<% folders.each do |name, opts| %>
|
<% folders.each do |name, opts| %>
|
||||||
"<%= opts[:hostpath] %>" <%= ip %>(rw,no_subtree_check,all_squash<% if opts[:map_uid] %>,anonuid=<%= opts[:map_uid] %><% end %><% if opts[:map_gid] %>,anongid=<%= opts[:map_gid] %><% end %>,fsid=<%= opts[:uuid] %>)
|
"<%= opts[:hostpath] %>" <%= ip %>(<%= opts[:linux__nfs_options].join(",") %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
# VAGRANT-END: <%= user %> <%= uuid %>
|
# VAGRANT-END: <%= user %> <%= uuid %>
|
||||||
|
|
Loading…
Reference in New Issue