# $Id: nfs_export.rb 2613 2009-06-21 17:43:52Z uwaechte $Puppet::Type.newtype(:nfs_export) do@doc="Manages nfs-server's /etc/exports file."
ensurable
newproperty(:export_point) do
desc "The directory which is exported"
isnamevar
endnewproperty(:client) do
desc "The client addresses (or wildcards) to which the export_point should be exported" # check for invalid characters
validate do |value|
unless value =~/[-\w\*\?\/\@\.]+/raiseArgumentError, "%s is not a valid client specification"% value
endendendnewproperty(:options) do
desc "Export options in linux-style notation. Those options that are applicable in FreeBSD are converted automatically."
defaultto "rw,no_subtree_check"
munge do |value|
ifFacter.value(:kernel) =="FreeBSD"linux_to_bsd_options(value)
elsesuperendenddeflinux_to_bsd_options(opts)
options = []
optarr = opts.split(",")
optarr.each {|opt|
case opt
when"ro":
options <<"-ro"when"no_root_squash"
options <<"-maproot=root"when"root_squash"
uid=nil
gid=nil
optarr.each {|k|
case k
when/anonuid=(.*)/
uid=$1when/anongid=(.*)/
gid=$1end
}
map=[]
if!uid.nil?
map << uid.to_sendif!gid.nil?
map << gid.to_sendif map.length>0
maps = map.join(":")
else
maps ="root"end
options <<"-maproot=#{maps}"when"all_squash"
uid=nil
gid=nil
optarr.each {|k|
case k
when/anonuid=(.*)/
uid=$1when/anongid=(.*)/
gid=$1end
}
map=[]
if!uid.nil?
map << uid.to_sendif!gid.nil?
map << gid.to_sendif map.length>0
maps = map.join(":")
else
maps ="nobody"end
options <<"-mapall=#{maps}"end
}
return options.join(" ")
endendnewparam(:name, :namevar => true) do
desc "The name of this export"endend