Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ The following parameters are available in the `nfs::client::mount` defined type:
* [`group`](#-nfs--client--mount--group)
* [`mode`](#-nfs--client--mount--mode)
* [`mount_root`](#-nfs--client--mount--mount_root)
* [`umask`](#-nfs--client--mount--umask)
* [`mount`](#-nfs--client--mount--mount)
* [`manage_packages`](#-nfs--client--mount--manage_packages)
* [`client_packages`](#-nfs--client--mount--client_packages)
Expand Down Expand Up @@ -903,6 +904,14 @@ Overwrite mount root if differs from server configuration.

Default value: `undef`

##### <a name="-nfs--client--mount--umask"></a>`umask`

Data type: `Optional[Stdlib::Filemode]`

Set umask for mount directory creation.

Default value: `undef`

##### <a name="-nfs--client--mount--mount"></a>`mount`

Data type: `String[1]`
Expand Down Expand Up @@ -945,6 +954,7 @@ The following parameters are available in the `nfs::functions::bindmount` define

* [`mount_name`](#-nfs--functions--bindmount--mount_name)
* [`ensure`](#-nfs--functions--bindmount--ensure)
* [`umask`](#-nfs--functions--bindmount--umask)

##### <a name="-nfs--functions--bindmount--mount_name"></a>`mount_name`

Expand All @@ -962,6 +972,14 @@ Sets if enabled or not.

Default value: `'present'`

##### <a name="-nfs--functions--bindmount--umask"></a>`umask`

Data type: `Optional[Stdlib::Filemode]`

Set umask for mount directory creation.

Default value: `undef`

### <a name="nfs--functions--create_export"></a>`nfs::functions::create_export`

Manage export creation.
Expand Down Expand Up @@ -1032,6 +1050,7 @@ Manage directory creation.
The following parameters are available in the `nfs::functions::mkdir` defined type:

* [`ensure`](#-nfs--functions--mkdir--ensure)
* [`umask`](#-nfs--functions--mkdir--umask)

##### <a name="-nfs--functions--mkdir--ensure"></a>`ensure`

Expand All @@ -1041,6 +1060,14 @@ Data type: `String[1]`

Default value: `'present'`

##### <a name="-nfs--functions--mkdir--umask"></a>`umask`

Data type: `Optional[Stdlib::Filemode]`



Default value: `undef`

### <a name="nfs--functions--nfsv4_bindmount"></a>`nfs::functions::nfsv4_bindmount`

Manage bindmounts for NFS v4.
Expand All @@ -1052,6 +1079,7 @@ The following parameters are available in the `nfs::functions::nfsv4_bindmount`
* [`v4_export_name`](#-nfs--functions--nfsv4_bindmount--v4_export_name)
* [`bind`](#-nfs--functions--nfsv4_bindmount--bind)
* [`ensure`](#-nfs--functions--nfsv4_bindmount--ensure)
* [`umask`](#-nfs--functions--nfsv4_bindmount--umask)

##### <a name="-nfs--functions--nfsv4_bindmount--v4_export_name"></a>`v4_export_name`

Expand All @@ -1073,6 +1101,14 @@ Sets if mounted or not.

Default value: `'mounted'`

##### <a name="-nfs--functions--nfsv4_bindmount--umask"></a>`umask`

Data type: `Optional[Stdlib::Filemode]`

Set umask for mount directory creation.

Default value: `undef`

### <a name="nfs--server--export"></a>`nfs::server::export`

Manage all exported resources on a NFS server.
Expand Down
6 changes: 6 additions & 0 deletions manifests/client/mount.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
# @param mount_root
# Overwrite mount root if differs from server configuration.
#
# @param umask
# Set umask for mount directory creation.
#
# @param mount
# @param manage_packages
# @param client_packages
Expand Down Expand Up @@ -83,6 +86,7 @@
Optional[String[1]] $mount_root = undef,
Boolean $manage_packages = $nfs::manage_packages,
Optional[Variant[String[1], Array[String[1]]]] $client_packages = $nfs::effective_client_packages,
Optional[Stdlib::Filemode] $umask = undef,
) {
if $manage_packages and $client_packages != undef {
$mount_require = [Nfs::Functions::Mkdir[$mount], Package[$client_packages]]
Expand All @@ -105,6 +109,7 @@

nfs::functions::mkdir { $mount:
ensure => $ensure,
umask => $umask,
}

mount { "shared ${sharename} by ${server} on ${mount}":
Expand Down Expand Up @@ -133,6 +138,7 @@

nfs::functions::mkdir { $mount:
ensure => $ensure,
umask => $umask,
}
mount { "shared ${sharename} by ${server} on ${mount}":
ensure => $ensure,
Expand Down
5 changes: 5 additions & 0 deletions manifests/functions/bindmount.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
# @param ensure
# Sets if enabled or not.
#
# @param umask
# Set umask for mount directory creation.
#
# @author
# * Daniel Klockenkaemper <dk@marketing-factory.de>
# * Martin Alfke <tuxmea@gmail.com>
#
define nfs::functions::bindmount (
Optional[String[1]] $mount_name = undef,
String[1] $ensure = 'present',
Optional[Stdlib::Filemode] $umask = undef,
) {
nfs::functions::mkdir { $mount_name:
ensure => $ensure,
umask => $umask,
}
mount { $mount_name:
ensure => $ensure,
Expand Down
9 changes: 8 additions & 1 deletion manifests/functions/mkdir.pp
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# @summary Manage directory creation.
#
# @param ensure
# @param umask
#
# @author
# * Daniel Klockenkaemper <dk@marketing-factory.de>
# * Martin Alfke <tuxmea@gmail.com>
#
define nfs::functions::mkdir (
String[1] $ensure = 'present',
Optional[Stdlib::Filemode] $umask = undef,
) {
if $ensure != 'absent' {
$_command = $umask ? {
undef => "mkdir -p ${name}",
default => "bash -c 'umask ${umask} && mkdir -p ${name}'",
}

exec { "mkdir_recurse_${name}":
path => ['/bin', '/usr/bin'],
command => "mkdir -p ${name}",
command => $_command,
unless => "test -d ${name}",
}
}
Expand Down
5 changes: 5 additions & 0 deletions manifests/functions/nfsv4_bindmount.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
# @param ensure
# Sets if mounted or not.
#
# @param umask
# Set umask for mount directory creation.
#
# @author
# * Daniel Klockenkaemper <dk@marketing-factory.de>
# * Martin Alfke <tuxmea@gmail.com>
Expand All @@ -17,11 +20,13 @@
String[1] $v4_export_name,
String[1] $bind,
String[1] $ensure = 'mounted',
Optional[Stdlib::Filemode] $umask = undef,
) {
$normalize_export_root = regsubst($nfs::server::nfs_v4_export_root, '/$', '')
$expdir = "${normalize_export_root}/${v4_export_name}"
nfs::functions::mkdir { $expdir:
ensure => $ensure,
umask => $umask,
}
mount { $expdir:
ensure => $ensure,
Expand Down
22 changes: 22 additions & 0 deletions spec/defines/client_mount_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

it { is_expected.to contain_nfs__functions__mkdir('/srv/test') }

it { is_expected.to contain_exec('mkdir_recurse_/srv/test').with(command: 'mkdir -p /srv/test') }

it do
is_expected.to contain_mount('shared /srv/test by 1.2.3.4 on /srv/test').that_requires(
[
Expand Down Expand Up @@ -131,6 +133,26 @@
)
end
end

context 'when nfs_v4 => false, non-default umask' do
let(:title) { '/srv/test' }

let(:pre_condition) { 'class { "nfs": client_enabled => true }' }

let(:params) { { server: '1.2.3.4', umask: '0022' } }

it { is_expected.to contain_nfs__functions__mkdir('/srv/test') }

it { is_expected.to contain_exec('mkdir_recurse_/srv/test').with(command: "bash -c 'umask 0022 && mkdir -p /srv/test'") }

it do
is_expected.to contain_mount('shared /srv/test by 1.2.3.4 on /srv/test').that_requires(
[
'Nfs::Functions::Mkdir[/srv/test]',
] + client_packages,
)
end
end
end
end
end
Loading