From b394d9b43727c1efc307a5833edb3d244c91633a Mon Sep 17 00:00:00 2001
From: Thomas Bellman <bellman@nsc.liu.se>
Date: Mon, 12 Dec 2022 17:34:39 +0100
Subject: [PATCH] Accept generalized lists as named_vhost servernames.

Accept not only a flat list as the 'servernames' parameter in the
named_vhost definition, but also simple strings and nested lists.
---
 manifests/named_vhost.pp       | 1 +
 templates/named_vhost.conf.erb | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/manifests/named_vhost.pp b/manifests/named_vhost.pp
index 03a7631..4caaa09 100644
--- a/manifests/named_vhost.pp
+++ b/manifests/named_vhost.pp
@@ -18,6 +18,7 @@
  *    Which hostnames in URLs this virtual host applies to.  Translates
  *    into 'ServerName' and 'ServerAlias' directives.  Defaults to the
  *    hostnames (before resolving) in the 'urls' parameter if not specified.
+ *    This can be a single string, or a (possibly nested) list of strings.
  *
  *  - certname
  *    If set, specifies the basename of server certificate files, for
diff --git a/templates/named_vhost.conf.erb b/templates/named_vhost.conf.erb
index 9382aab..51321bf 100644
--- a/templates/named_vhost.conf.erb
+++ b/templates/named_vhost.conf.erb
@@ -1,5 +1,5 @@
 <%
-    # Copyright (C) 2014-2020 Thomas Bellman.
+    # Copyright (C) 2014-2022 Thomas Bellman.
     # Licensed under the GNU LGPL v3+; see the README file for more information.
 
     httpd_version = scope.lookupvar('apache::standard_version')
@@ -48,7 +48,7 @@
 	end
     end
     if @servernames != []
-	server_names = @servernames
+	server_names = [@servernames].flatten
     end
     server_addrs.sort!.uniq!
 -%>
-- 
GitLab