From e567b96195c0cbd4e05d18bd85ebd8a655ed59de Mon Sep 17 00:00:00 2001 From: Brian Schonecker Date: Mon, 20 May 2024 11:17:48 -0400 Subject: [PATCH] Add boolean variable to control whether or not to create the directory path exported by the NFS server. --- README.md | 6 ++++-- manifests/functions/create_export.pp | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) 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,