diff --git a/README.md b/README.md index 8ee4b42a..88ebe020 100644 --- a/README.md +++ b/README.md @@ -143,10 +143,12 @@ This will mount /data on client in /share/data. } # ensure is passed to mount, which will make the client not mount it # the directory automatically, just add it to fstab + # The directory on the NFS server is not created automatically. nfs::server::export { '/media_library': - ensure => 'present', + ensure => 'present', nfstag => 'media', - clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)', + clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)', + create_dir => false, } } diff --git a/manifests/functions/create_export.pp b/manifests/functions/create_export.pp index 585fa10c..e0181ce6 100644 --- a/manifests/functions/create_export.pp +++ b/manifests/functions/create_export.pp @@ -11,6 +11,9 @@ # [*ensure*] # String. Sets if enabled or not. # +# [*create_dir*] +# Boolean. Create the directory to be exported. +# # [*owner*] # String. Sets the owner of the exported directory. # @@ -37,6 +40,7 @@ define nfs::functions::create_export ( $clients, $ensure = 'present', + Boolean $create_dir = true, $owner = undef, $group = undef, $mode = undef, @@ -49,7 +53,9 @@ content => $line, } - unless defined(File[$name]) { + # Create the directory path only if a File resource isn't + # defined previously AND the $create_dir boolean is true. + unless defined(File[$name]) and $create_dir { filepath { $name: ensure => present, owner => $owner, diff --git a/manifests/server/export.pp b/manifests/server/export.pp index 84d653d2..2dd40182 100644 --- a/manifests/server/export.pp +++ b/manifests/server/export.pp @@ -52,6 +52,9 @@ # String. Sets the hostname clients will use to mount the exported resource. If undef it # defaults to the trusted certname # +# [*create_dir*] +# Boolean. Create the directory to be exported. +# # === Examples # # class { '::nfs': @@ -96,6 +99,7 @@ $mode = undef, $server = $::clientcert, $nfsv4_bindmount_enable = $::nfs::nfsv4_bindmount_enable, + Boolean $create_dir = true, ) { if $nfs::server::nfs_v4 { @@ -118,12 +122,13 @@ } nfs::functions::create_export { $export_title: - ensure => $ensure, - clients => $clients, - owner => $owner, - group => $group, - mode => $mode, - require => $create_export_require, + ensure => $ensure, + clients => $clients, + create_dir => $create_dir, + owner => $owner, + group => $group, + mode => $mode, + require => $create_export_require, } if $mount != undef {