Skip to content

Commit ebfff6a

Browse files
committed
Add beginning of support for external NFS servers
1 parent 943b2c1 commit ebfff6a

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

site/profile/manifests/nfs.pp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
class profile::nfs::client (
1313
String $server_ip,
1414
String $domain_name,
15+
Array[String] $shares = [],
1516
) {
1617
$nfs_domain = "int.${domain_name}"
1718

@@ -23,18 +24,24 @@
2324

2425
$instances = lookup('terraform.instances')
2526
$nfs_server = Hash($instances.map| $key, $values | { [$values['local_ip'], $key] })[$server_ip]
26-
$nfs_volumes = $instances.dig($nfs_server, 'volumes', 'nfs')
27-
if $nfs_volumes =~ Hash[String, Hash] {
27+
if $nfs_server {
28+
$nfs_volumes = $instances.dig($nfs_server, 'volumes', 'nfs')
2829
$nfs_export_list = keys($nfs_volumes)
29-
$options_nfsv4 = 'proto=tcp,nosuid,nolock,noatime,actimeo=3,nfsvers=4.2,seclabel,x-systemd.automount,x-systemd.mount-timeout=30,_netdev'
30-
$nfs_export_list.each | String $name | {
31-
nfs::client::mount { "/${name}":
32-
ensure => present,
33-
server => $server_ip,
34-
share => $name,
35-
options_nfsv4 => $options_nfsv4,
36-
notify => Systemd::Daemon_reload['nfs-automount'],
37-
}
30+
$nfs_options = 'proto=tcp,nosuid,nolock,noatime,actimeo=3,nfsvers=4.2,seclabel'
31+
} else {
32+
# The NFS server is not an instance created by Magic Castle and managed by Terraform.
33+
$nfs_export_list = $shares
34+
$nfs_options = 'nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport'
35+
}
36+
37+
$options_nfsv4 = "${nfs_options},x-systemd.automount,x-systemd.mount-timeout=30,_netdev"
38+
$nfs_export_list.each | String $name | {
39+
nfs::client::mount { "/${name}":
40+
ensure => present,
41+
server => $server_ip,
42+
share => $name,
43+
options_nfsv4 => $options_nfsv4,
44+
notify => Systemd::Daemon_reload['nfs-automount'],
3845
}
3946
}
4047

0 commit comments

Comments
 (0)