From 3e7153b906e7ae63854ad50f83ce2ca69ed4919e Mon Sep 17 00:00:00 2001
From: Fabien COMBERNOUS <fabien.combernous@adullact.org>
Date: Thu, 27 Mar 2025 10:48:14 +0100
Subject: [PATCH] handle several listmasters

---
 manifests/init.pp          |  4 ++--
 spec/classes/sympa_spec.rb | 28 ++++++++++++++++++++++++++++
 templates/sympa.conf.epp   |  2 +-
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/manifests/init.pp b/manifests/init.pp
index bf2f9cf..38cec5d 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -17,7 +17,7 @@
 # @param listdomain
 #   Primary mail domain name. Web interface for Sympa mailing list manager, can
 #   be joined at https://$listdomain
-# @param listmaster Email addresses of listmaster
+# @param listmaster Email addresses of listmasters
 # @param lang Supported language
 # @param topics Defines topics (categories) of the mailing lists.
 #
@@ -37,7 +37,7 @@ class sympa (
   String[1] $aliases_file = 'sympa_aliases',
   String[1] $release = '6.2.74',
   Stdlib::Fqdn $listdomain = 'listes.example.org',
-  Stdlib::Email $listmaster = 'listmaster@example.org',
+  Array[Stdlib::Email] $listmaster = ['listmaster@example.org'],
   Enum['fr'] $lang = 'fr',
   Sympa::Topics $topics = {},
 ) {
diff --git a/spec/classes/sympa_spec.rb b/spec/classes/sympa_spec.rb
index 11fa094..292dad4 100644
--- a/spec/classes/sympa_spec.rb
+++ b/spec/classes/sympa_spec.rb
@@ -28,6 +28,34 @@ describe 'sympa' do
 
         it { is_expected.to compile.with_all_deps }
       end
+
+      context 'with only one listmaster email address' do
+        let(:params) do
+          {
+            listmaster: ['lm1@example.com'],
+          }
+        end
+
+        it { is_expected.to compile.with_all_deps }
+        it do
+          is_expected.to contain_file('/home/sympa/etc/sympa.conf') \
+            .with_content(%r{^listmaster\s+lm1@example\.com$})
+        end
+      end
+
+      context 'with several listmaster email addresses' do
+        let(:params) do
+          {
+            listmaster: ['lm1@example.com', 'lm2@example.com'],
+          }
+        end
+
+        it { is_expected.to compile.with_all_deps }
+        it do
+          is_expected.to contain_file('/home/sympa/etc/sympa.conf') \
+            .with_content(%r{^listmaster\s+lm1@example\.com,lm2@example\.com$})
+        end
+      end
     end
   end
 end
diff --git a/templates/sympa.conf.epp b/templates/sympa.conf.epp
index f45a1b1..e11f7fa 100644
--- a/templates/sympa.conf.epp
+++ b/templates/sympa.conf.epp
@@ -4,7 +4,7 @@
 ########################################################################
 
 domain              <%= $sympa::listdomain %>
-listmaster          <%= $sympa::listmaster %>
+listmaster          <%= $sympa::listmaster.join(',') %>
 lang                <%= $sympa::lang %>
 
 ########################################################################
-- 
GitLab