Skip to content

Commit efe9500

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 e08f113 commit efe9500

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

REFERENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ Default value: `'/export'`
377377

378378
##### <a name="-nfs--nfs_v4_export_root_clients"></a>`nfs_v4_export_root_clients`
379379

380-
Data type: `String`
380+
Data type: `Variant[String, Array[String]]`
381381

382382
It defines the clients that are allowed to mount NFS version 4 exports and includes the option string.
383383

@@ -708,7 +708,7 @@ Default value: `$nfs::nfs_v4_export_root`
708708

709709
##### <a name="-nfs--server--nfs_v4_export_root_clients"></a>`nfs_v4_export_root_clients`
710710

711-
Data type: `String`
711+
Data type: `Variant[String, Array[String]]`
712712

713713

714714

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: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,26 @@
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+
408+
it do
409+
is_expected.to contain_concat__fragment('nfs_exports_root').
410+
with_target('/etc/exports').
411+
with_content(%r{/export 192\.0\.2\.1 192\.0\.2\.2})
412+
end
413+
end
414+
405415
context 'when nfs_v4 => true' do
406416
let(:params) { { nfs_v4: true, server_enabled: true, client_enabled: false, nfs_v4_idmap_domain: 'teststring' } }
417+
let(:node) { 'test.local' }
418+
419+
it do
420+
is_expected.to contain_concat__fragment('nfs_exports_root').
421+
with_target('/etc/exports').
422+
with_content(%r{/export \*\.local\(ro,fsid=root,insecure,no_subtree_check,async,root_squash\)})
423+
end
407424

408-
it { is_expected.to contain_concat__fragment('nfs_exports_root').with('target' => '/etc/exports') }
409425
it { is_expected.to contain_file('/export').with('ensure' => 'directory') }
410426
it { is_expected.to contain_augeas('/etc/idmapd.conf').with_changes(%r{set General/Domain teststring}) }
411427

0 commit comments

Comments
 (0)