diff --git a/README.md b/README.md
index be9d937..e5e7bc8 100644
--- a/README.md
+++ b/README.md
@@ -152,10 +152,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',
nfstag => 'media',
clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)',
+ create_dir => false,
}
}
diff --git a/REFERENCE.md b/REFERENCE.md
index ad547db..35ba4dd 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -1109,6 +1109,7 @@ The following parameters are available in the `nfs::functions::create_export` de
* [`owner`](#-nfs--functions--create_export--owner)
* [`group`](#-nfs--functions--create_export--group)
* [`mode`](#-nfs--functions--create_export--mode)
+* [`create_dir`](#-nfs--functions--create_export--create_dir)
##### `clients`
@@ -1148,6 +1149,15 @@ String. Sets the permissions of the exported directory.
Default value: `undef`
+##### `create_dir`
+
+Data type: `Boolean`
+
+Boolean. Create the directory to be exported.
+Defaults to true.
+
+Default value: `true`
+
### `nfs::functions::mkdir`
Function: nfs::functions::mkdir
@@ -1260,6 +1270,7 @@ The following parameters are available in the `nfs::server::export` defined type
* [`v3_export_name`](#-nfs--server--export--v3_export_name)
* [`v4_export_name`](#-nfs--server--export--v4_export_name)
* [`nfsv4_bindmount_enable`](#-nfs--server--export--nfsv4_bindmount_enable)
+* [`create_dir`](#-nfs--server--export--create_dir)
##### `clients`
@@ -1402,3 +1413,12 @@ Data type: `Boolean`
Default value: `$nfs::nfsv4_bindmount_enable`
+##### `create_dir`
+
+Data type: `Boolean`
+
+Boolean. Create the directory to be exported.
+Defaults to true.
+
+Default value: `true`
+
diff --git a/manifests/functions/create_export.pp b/manifests/functions/create_export.pp
index b610135..5d959d1 100644
--- a/manifests/functions/create_export.pp
+++ b/manifests/functions/create_export.pp
@@ -19,6 +19,10 @@
# @param mode
# String. Sets the permissions of the exported directory.
#
+# @param create_dir
+# Boolean. Create the directory to be exported.
+# Defaults to true.
+#
# @author
# * Daniel Klockenkaemper
# * Martin Alfke
@@ -26,6 +30,7 @@
define nfs::functions::create_export (
Variant[String[1], Array[String[1]]] $clients,
String[1] $ensure = 'present',
+ Boolean $create_dir = true,
Optional[String[1]] $owner = undef,
Optional[String[1]] $group = undef,
Optional[String[1]] $mode = undef,
@@ -38,13 +43,16 @@
content => $line,
}
+ # Create the directory path only if a File resource isn't
+ # # defined previously AND the $create_dir boolean is true.
unless defined(File[$name]) {
- file { $name:
- ensure => directory,
- owner => $owner,
- group => $group,
- mode => $mode,
- selinux_ignore_defaults => true,
+ if $create_dir {
+ file { $name:
+ ensure => directory,
+ owner => $owner,
+ group => $group,
+ mode => $mode,
+ }
}
}
}
diff --git a/manifests/server/export.pp b/manifests/server/export.pp
index 3b5a26b..f15312b 100644
--- a/manifests/server/export.pp
+++ b/manifests/server/export.pp
@@ -57,7 +57,11 @@
# @param v4_export_name
# @param nfsv4_bindmount_enable
#
-# @examples
+# @param create_dir
+# Boolean. Create the directory to be exported.
+# Defaults to true.
+#
+# @example
#
# class { '::nfs':
# server_enabled => true,
@@ -101,6 +105,7 @@
Optional[String[1]] $mode = undef,
String[1] $server = $facts['clientcert'],
Boolean $nfsv4_bindmount_enable = $nfs::nfsv4_bindmount_enable,
+ Boolean $create_dir = true,
) {
if $nfs::server::nfs_v4 {
if $nfsv4_bindmount_enable {
@@ -120,12 +125,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 {
@@ -154,11 +160,12 @@
}
nfs::functions::create_export { $v3_export_name:
- ensure => $ensure,
- clients => $clients,
- owner => $owner,
- group => $group,
- mode => $mode,
+ ensure => $ensure,
+ clients => $clients,
+ create_dir => $create_dir,
+ owner => $owner,
+ group => $group,
+ mode => $mode,
}
if $nfs::storeconfigs_enabled {
diff --git a/metadata.json b/metadata.json
index a483a44..d3269c2 100644
--- a/metadata.json
+++ b/metadata.json
@@ -12,6 +12,7 @@
{"name":"puppetlabs/concat","version_requirement":">= 1.1.2 < 10.0.0"},
{"name":"puppetlabs/transition","version_requirement":">= 0.1.0 < 3.0.0"},
{"name":"puppet/augeasproviders_core","version_requirement":">= 2.1.5 < 5.0.0"},
+ {"name":"edgej-filepath","version_requirement":">= 1.0.0"},
{"name":"puppet/augeasproviders_shellvar","version_requirement":">= 1.2.0 <= 7.0.0"},
{"name":"puppetlabs/augeas_core","version_requirement":">= 1.2.0 <= 2.0.0"},
{"name":"puppetlabs/mount_core","version_requirement":">= 1.2.0 <= 2.0.0"}