From 577278421b7ff2e9e2749182c3eead6a06e490c0 Mon Sep 17 00:00:00 2001
From: Thomas Bellman <bellman@nsc.liu.se>
Date: Wed, 4 Apr 2018 19:19:21 +0200
Subject: [PATCH] Don't generate NameVirtualHost directives for v2.4.

The NameVirtualHost directive has been deprecated since version 2.3.11
of httpd; now name-based virtual hosting is automatically enabled for
any IP/port combination used in more than one <VirtualHost> directive.
NameVirtualHost is now a no-op, but gives a warning on startup, so
don't generate those directives when running newer versions of httpd.
---
 templates/named_vhost.conf.erb | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/templates/named_vhost.conf.erb b/templates/named_vhost.conf.erb
index bf29790..9e72c47 100644
--- a/templates/named_vhost.conf.erb
+++ b/templates/named_vhost.conf.erb
@@ -1,4 +1,6 @@
 <%
+    httpd_version = scope.lookupvar('apache::standard_version')
+
     server_names = []
     server_addrs = []
     [@urls].flatten.sort.each do |u|
@@ -57,8 +59,12 @@
 ##	cfg << 'DocumentRoot ' + @documentroot
 ##    end
 -%>
-<% server_addrs.each do |addr| -%>
+<% if (httpd_version  and  httpd_version != ''  and
+       scope.function_versioncmp([httpd_version, '2.3.11']) < 0)
+      server_addrs.each do |addr|
+-%>
 NameVirtualHost <%= addr %>
+<%    end -%>
 <% end -%>
 <VirtualHost <%= server_addrs.join(' ') %>>
 
-- 
GitLab