From 8777f4a6002ca1531241d40c5bd32f40c8eb92a3 Mon Sep 17 00:00:00 2001 From: Max Carrara Date: Tue, 2 Apr 2024 16:55:16 +0200 Subject: [PATCH] cephconfig: allow writing arbitrary sections This adds support for writing arbitrary sections to 'ceph.conf' while ensuring that already written sections are not duplicated. Signed-off-by: Max Carrara Tested-by: Friedrich Weber --- src/PVE/CephConfig.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/PVE/CephConfig.pm b/src/PVE/CephConfig.pm index 9934fd5..1fb467d 100644 --- a/src/PVE/CephConfig.pm +++ b/src/PVE/CephConfig.pm @@ -60,6 +60,7 @@ my $parse_ceph_file = sub { sub write_ceph_config { my ($filename, $cfg) = @_; + my $written_sections = {}; my $out = ''; my $cond_write_sec = sub { @@ -67,12 +68,15 @@ sub write_ceph_config { for my $section (sort keys $cfg->%*) { next if $section !~ m/^$re$/; + next if exists($written_sections->{$section}); $out .= "[$section]\n"; for my $key (sort keys $cfg->{$section}->%*) { $out .= "\t $key = $cfg->{$section}->{$key}\n"; } $out .= "\n"; + + $written_sections->{$section} = 1; } }; @@ -89,6 +93,8 @@ sub write_ceph_config { qr/mon\..*/, qr/osd\..*/, qr/mgr\..*/, + + qr/.*/, ); for my $re (@rexprs) {