From ef03095f089b9b952f13bfc57306e87d008aa18c Mon Sep 17 00:00:00 2001 From: Thomas Bellman <bellman@nsc.liu.se> Date: Fri, 3 May 2024 17:52:11 +0200 Subject: [PATCH] Let named_vhost listen on URLs automatically. Now that we support calling apache::listen multiple times on the same address/port pair, we can let apache::named_vhost automatically listen on the URLs it will handle. Do so. This will make it a little bit easier for users, who will no longer need to instantiate both an apache::named_vhost resource, *and* an apache::listen resource. Perhaps not a huge deal, especially since we now allow multiple apache::listen resources for the same address/ port pairs, but even a little bit helps. --- manifests/named_vhost.pp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/manifests/named_vhost.pp b/manifests/named_vhost.pp index 4caaa09..64a060b 100644 --- a/manifests/named_vhost.pp +++ b/manifests/named_vhost.pp @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2022 Thomas Bellman. +# Copyright (C) 2014-2024 Thomas Bellman. # Licensed under the GNU LGPL v3+; see the README file for more information. @@ -10,9 +10,11 @@ * - urls * Specifies one or more addresses that this virtual host handles, i.e. * which 'Listen' directives apply to it, on the format of URLs, in the - * same format as apache::listen does. Listen directives must however - * be configured separately; this definition does not do that for you. - * This parameter can be either a single URL, or a list of URLs. + * same format as apache::listen does. apache::listen will be called + * automatically, so you don't need to do that separately (this is a new + * behaviour since 2024). + * This parameter can be either a single URL, or a (possibly nested) + * list of URLs. * * - servernames * Which hostnames in URLs this virtual host applies to. Translates @@ -62,6 +64,10 @@ define apache::named_vhost($urls, if $certname { include x509certs } + apache::listen { + "_vhost-${name}": + urls => $urls; + } apache::include_file { "vhost-${name}": content => template('apache/named_vhost.conf.erb'), @@ -69,6 +75,10 @@ define apache::named_vhost($urls, } } 'absent': { + apache::listen { + "_vhost-${name}": + ensure => absent; + } apache::include_file { "vhost-${name}": ensure => absent; -- GitLab