Skip to content

Commit

Permalink
Add boolean variable to control whether or not to create the director…
Browse files Browse the repository at this point in the history
…y path exported by the NFS server.
  • Loading branch information
bschonec committed May 20, 2024
1 parent 1a02fb3 commit e567b96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
8 changes: 7 additions & 1 deletion manifests/functions/create_export.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -37,6 +40,7 @@
define nfs::functions::create_export (
$clients,
$ensure = 'present',
Boolean $create_dir = true,
$owner = undef,
$group = undef,
$mode = undef,
Expand All @@ -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,
Expand Down

0 comments on commit e567b96

Please sign in to comment.