Skip to content

Commit dfd946b

Browse files
committed
nfs::server: allow arrays for nfs_v4_export_root_clients
The config for nfs_v4_export_root_clients looks horrible when you have multiple nfs clients. Update config to allow using arrays
1 parent 8229c4d commit dfd946b

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
String $client_gssdopt_name = $nfs::params::client_gssdopt_name,
238238
Boolean $client_d9_gssdopt_workaround = false,
239239
String $nfs_v4_export_root = '/export',
240-
String $nfs_v4_export_root_clients = "*.${facts['networking']['domain']}(ro,fsid=root,insecure,no_subtree_check,async,root_squash)",
240+
Variant[String, Array[String]] $nfs_v4_export_root_clients = "*.${facts['networking']['domain']}(ro,fsid=root,insecure,no_subtree_check,async,root_squash)",
241241
String $nfs_v4_mount_root = '/srv',
242242
String $nfs_v4_idmap_domain = $nfs::params::nfs_v4_idmap_domain,
243243
Variant[String, Array] $nfs_v4_idmap_localrealms = '', # lint:ignore:params_empty_string_assignment

manifests/server.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Enum['present', 'absent', 'running', 'stopped', 'disabled'] $ensure = $nfs::ensure,
2626
Boolean $nfs_v4 = $nfs::nfs_v4,
2727
String $nfs_v4_export_root = $nfs::nfs_v4_export_root,
28-
String $nfs_v4_export_root_clients = $nfs::nfs_v4_export_root_clients,
28+
Variant[String, Array[String]] $nfs_v4_export_root_clients = $nfs::nfs_v4_export_root_clients,
2929
String $nfs_v4_idmap_domain = $nfs::nfs_v4_idmap_domain,
3030
String $nfs_v4_root_export_ensure = $nfs::nfs_v4_root_export_ensure,
3131
Optional[String] $nfs_v4_root_export_mount = $nfs::nfs_v4_root_export_mount,

manifests/server/config.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
if $nfs::nfs_v4 {
1919
if $nfs::nfsv4_bindmount_enable {
20+
$nfs_v4_clients = Array($nfs::server::nfs_v4_export_root_clients, true).join(' ')
2021
concat::fragment { 'nfs_exports_root':
2122
target => $nfs::exports_file,
22-
content => "${nfs::server::nfs_v4_export_root} ${nfs::server::nfs_v4_export_root_clients}\n",
23+
content => "${nfs::server::nfs_v4_export_root} ${nfs_v4_clients}\n",
2324
order => 2,
2425
}
2526
}

spec/classes/nfs_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,22 @@
402402
end
403403
end
404404

405+
context 'when nfs_v4_export_root_clients is an array' do
406+
let(:params) { { nfs_v4: true, server_enabled: true, nfs_v4_export_root_clients: ['192.0.2.1', '192.0.2.2'] } }
407+
it do
408+
is_expected.to contain_concat__fragment('nfs_exports_root').
409+
with_target('/etc/exports').
410+
with_content(%r{/export 192\.0\.2\.1 192\.0\.2\.2})
411+
end
412+
end
405413
context 'when nfs_v4 => true' do
406414
let(:params) { { nfs_v4: true, server_enabled: true, client_enabled: false, nfs_v4_idmap_domain: 'teststring' } }
407415

408-
it { is_expected.to contain_concat__fragment('nfs_exports_root').with('target' => '/etc/exports') }
416+
it do
417+
is_expected.to contain_concat__fragment('nfs_exports_root').
418+
with_target('/etc/exports').
419+
with_content(%r{/export \*\.local\(ro,fsid=root,insecure,no_subtree_check,async,root_squash\)})
420+
end
409421
it { is_expected.to contain_file('/export').with('ensure' => 'directory') }
410422
it { is_expected.to contain_augeas('/etc/idmapd.conf').with_changes(%r{set General/Domain teststring}) }
411423

0 commit comments

Comments
 (0)