|
12 | 12 | class profile::nfs::client ( |
13 | 13 | String $server_ip, |
14 | 14 | String $domain_name, |
| 15 | + Array[String] $shares = [], |
15 | 16 | ) { |
16 | 17 | $nfs_domain = "int.${domain_name}" |
17 | 18 |
|
|
23 | 24 |
|
24 | 25 | $instances = lookup('terraform.instances') |
25 | 26 | $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') |
28 | 29 | $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'], |
38 | 45 | } |
39 | 46 | } |
40 | 47 |
|
|
0 commit comments