Skip to content
Open
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
19 changes: 14 additions & 5 deletions modules/ocf_filehost/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
}

ocf_filehost::nfs_export {
'/opt/homes':
# We don't root_squash admin, ssh, or apphost because they need to access
# /services/crontabs/$server/ as root.
options => ['rw', 'fsid=0', 'no_subtree_check', 'no_root_squash'],
hosts => ['admin', 'www', 'ssh', 'apphost', 'adenine', 'guanine', 'cytosine', 'thymine', 'fluttershy', 'rainbowdash'];
'/opt/homes': clients => [
{
# We don't root_squash admin, ssh, or apphost because they need to access
# /services/crontabs/$server/ as root.
options => ['rw', 'fsid=0', 'no_subtree_check', 'no_root_squash'],
hosts => ['admin', 'www', 'ssh', 'apphost', 'adenine', 'guanine', 'cytosine', 'thymine', 'fluttershy', 'rainbowdash'],
},
{
# allow other hosts (including desktops) to mount nfs, but with limitations (no
# root, strict subtree checking, kerberos auth/integrity/encryption.
options => ['rw', 'fsid=0', 'subtree_check', 'root_squash', 'sec=krb5p'],
hosts => ['*.ocf.berkeley.edu'],
},
],
}

file {
Expand Down
35 changes: 28 additions & 7 deletions modules/ocf_filehost/manifests/nfs_export.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
define ocf_filehost::nfs_export (
Array[String] $options,
Array[String] $hosts,
# allow specifying an export point that is different from the title; useful
# for exports where you want to specify different options for different
# groups of hosts that all share the same export point.
#
# a map is used so that each groups of hosts with the same export point are
# listed in the file as under the same export point:
# /path/to/dir \
# host1(opts) \
# host2(opts) \
# instead of:
# /path/to/dir \
# host1(opts) \
# /path/to/dir \
# host2(opts) \

Array[Struct[{
options => Array[String],
hosts => Array[String],
}]] $clients,
) {

$option_string = join($options, ',');
$hosts_plus_option = $hosts.map |$host| { " ${host}(${option_string})" };
$export_string = join($hosts_plus_option, " \\\n");
$export_chunks = $clients.map |$client| {
$option_string = join($client['options'], ',');
$hosts_plus_option = $client['hosts'].map |$host| { " ${host}(${option_string})" };
join($hosts_plus_option, " \\\n")
}

$export_string = join($export_chunks, " \\\n");

concat::fragment { "nfs-export-${name}":
concat::fragment { "nfs-export-${title}":
target => '/etc/exports',
content => "${name} \\\n${export_string}\n\n"
content => "${title} \\\n${export_string}\n\n"
}
}