Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request haraldsk#31 from CDLSoftware/issue30_setOwnershipT…
Browse files Browse the repository at this point in the history
…hroughExport

Issue haraldsk#30 Add ability to set owner,group,perms on server::export
  • Loading branch information
dwerder committed Jul 29, 2015
2 parents 39f2260 + ac2b4b8 commit 89a4ee9
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 93 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ and on individual nodes.
}
}
```
Set ownership and permissions on the folder being exported

```puppet
node server {
nfs::server::export{ '/data_folder':
ensure => 'mounted',
clients => '10.0.0.0/24(rw,insecure,no_subtree_check,async,no_root_squash) localhost(rw)',
owner => 'root',
group => 'root',
perms => '0755',
}
}
```

By default, mounts are mounted in the same folder on the clients as
they were exported from on the server
Expand Down
143 changes: 71 additions & 72 deletions manifests/server/export.pp
Original file line number Diff line number Diff line change
@@ -1,72 +1,71 @@
define nfs::server::export (
$v3_export_name = $name,
# Grab the final directory name in the given path and make it our default nfsv4 export name.
$v4_export_name = regsubst($name, '.*/([^/]+)/?$', '\1' ),
$clients = 'localhost(ro)',
$bind = 'rbind',
# globals for this share
# propogated to storeconfigs
$ensure = 'mounted',
$mount = undef,
$remounts = false,
$atboot = false,
$options = '_netdev',
$bindmount = undef,
$nfstag = undef,
$server = $::clientcert
) {
if $nfs::server::nfs_v4 {
nfs::server::export::nfs_v4::bindmount { $name:
ensure => $ensure,
v4_export_name => $v4_export_name,
bind => $bind,
}
nfs::server::export::configure{
"${nfs::server::nfs_v4_export_root}/${v4_export_name}":
ensure => $ensure,
clients => $clients,
require => Nfs::Server::Export::Nfs_v4::Bindmount[$name]
}
@@nfs::client::mount {"shared ${v4_export_name} by ${::clientcert}":
ensure => $ensure,
mount => $mount,
remounts => $remounts,
atboot => $atboot,
options => $options,
bindmount => $bindmount,
nfstag => $nfstag,
share => $v4_export_name,
server => $server,
}
} else {
nfs::server::export::configure{
$v3_export_name:
ensure => $ensure,
clients => $clients,
}
if $mount == undef {
$_mount = $v3_export_name
} else {
$_mount = $mount
}
@@nfs::client::mount {"shared ${v3_export_name} by ${::clientcert}":
ensure => $ensure,
mount => $_mount,
remounts => $remounts,
atboot => $atboot,
options => $options,
nfstag => $nfstag,
share => $v3_export_name,
server => $server,
}
}
}
define nfs::server::export (
$v3_export_name = $name,
# Grab the final directory name in the given path and make it our default nfsv4 export name.
$v4_export_name = regsubst($name, '.*/([^/]+)/?$', '\1'),
$clients = 'localhost(ro)',
$bind = 'rbind',
$owner = 'root',
$group = 'root',
$perms = '0755',
# globals for this share
# propogated to storeconfigs
$ensure = 'mounted',
$mount = undef,
$remounts = false,
$atboot = false,
$options = '_netdev',
$bindmount = undef,
$nfstag = undef,
$server = $::clientcert) {
if $nfs::server::nfs_v4 {
nfs::server::export::nfs_v4::bindmount { $name:
ensure => $ensure,
v4_export_name => $v4_export_name,
bind => $bind,
owner => $owner,
group => $group,
perms => $perms,
}
nfs::server::export::configure { "${nfs::server::nfs_v4_export_root}/${v4_export_name}":
ensure => $ensure,
clients => $clients,
require => Nfs::Server::Export::Nfs_v4::Bindmount[$name]
}
@@nfs::client::mount { "shared ${v4_export_name} by ${::clientcert}":
ensure => $ensure,
mount => $mount,
remounts => $remounts,
atboot => $atboot,
options => $options,
bindmount => $bindmount,
nfstag => $nfstag,
share => $v4_export_name,
server => $server,
}
} else {
nfs::server::export::configure { $v3_export_name:
ensure => $ensure,
clients => $clients,
}
if $mount == undef {
$_mount = $v3_export_name
} else {
$_mount = $mount
}
@@nfs::client::mount { "shared ${v3_export_name} by ${::clientcert}":
ensure => $ensure,
mount => $_mount,
remounts => $remounts,
atboot => $atboot,
options => $options,
nfstag => $nfstag,
share => $v3_export_name,
server => $server,
}
}
}
46 changes: 25 additions & 21 deletions manifests/server/export/nfs_v4/bindmount.pp
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
define nfs::server::export::nfs_v4::bindmount (
$v4_export_name,
$bind,
$ensure = 'mounted',
) {

$expdir = "${nfs::server::nfs_v4_export_root}/${v4_export_name}"

nfs::mkdir{ $expdir: }

mount {
$expdir:
ensure => $ensure,
device => $name,
atboot => true,
fstype => 'none',
options => $bind,
require => Nfs::Mkdir[$expdir],
}

}
define nfs::server::export::nfs_v4::bindmount (
$v4_export_name,
$bind,
$ensure = 'mounted',
$owner = 'root',
$group = 'root',
$perms = '0755') {
$expdir = "${nfs::server::nfs_v4_export_root}/${v4_export_name}"

nfs::mkdir { $expdir:
owner => $owner,
group => $group,
perm => $perms
}

mount { $expdir:
ensure => $ensure,
device => $name,
atboot => true,
fstype => 'none',
options => $bind,
require => Nfs::Mkdir[$expdir],
}

}

0 comments on commit 89a4ee9

Please sign in to comment.