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 4916df4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 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
17 changes: 11 additions & 6 deletions manifests/server/export.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -96,6 +99,7 @@
$mode = undef,
$server = $::clientcert,
$nfsv4_bindmount_enable = $::nfs::nfsv4_bindmount_enable,
Boolean $create_dir = true,
) {
if $nfs::server::nfs_v4 {
Expand All @@ -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 {
Expand Down

0 comments on commit 4916df4

Please sign in to comment.