Fix template variables

We almost never define $serveraliases which means that it's always going
to be empty. Puppet 4 is more strict about types and converting undef to
nil so this change makes sure that an undefined variable doesn't
accidentally get evaluated as existing and cause an invalid apache
config.

In the places where we're already just comparing @serveraliases to nil,
just leave them alone. Nil should be the expected value for undefined
variables going forward in puppet 4, so as long as it's working in
puppet 3 let's keep it.

Change-Id: I68ea8e1fde5d422f821453ff618d827e3cbe1c43
This commit is contained in:
Colleen Murphy 2018-07-12 09:41:44 +02:00
parent c8b38a40d8
commit b54344129d
6 changed files with 6 additions and 6 deletions

View File

@ -7,7 +7,7 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %>
ServerName <%= @srvname %> ServerName <%= @srvname %>
<% if @serveraliases.is_a? Array -%> <% if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != '' -%> <% elsif ! ['', nil].include?(@serveraliases) -%>
<%= " ServerAlias #{@serveraliases}" %> <%= " ServerAlias #{@serveraliases}" %>
<% end -%> <% end -%>

View File

@ -6,7 +6,7 @@
ServerName <%= @vhost_name %> ServerName <%= @vhost_name %>
<% if @serveraliases.is_a? Array -%> <% if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != '' -%> <% elsif ! ['', nil].include?(@serveraliases) -%>
<%= " ServerAlias #{@serveraliases}" %> <%= " ServerAlias #{@serveraliases}" %>
<% end -%> <% end -%>
RewriteEngine On RewriteEngine On

View File

@ -7,7 +7,7 @@
<% if @serveraliases.is_a? Array -%> <% if @serveraliases.is_a? Array -%>
# Permanently redirect these ServerAlias entries to ServerName # Permanently redirect these ServerAlias entries to ServerName
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != '' -%> <% elsif ! ['', nil].include?(@serveraliases) -%>
<%= " ServerAlias #{@serveraliases}" %> <%= " ServerAlias #{@serveraliases}" %>
RewriteEngine On RewriteEngine On
RewriteCond %{HTTP_HOST} !<%= @vhost_name %>$ [NC] RewriteCond %{HTTP_HOST} !<%= @vhost_name %>$ [NC]

View File

@ -6,7 +6,7 @@
ServerName <%= @vhost_name %> ServerName <%= @vhost_name %>
<% if @serveraliases.is_a? Array -%> <% if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != '' -%> <% elsif ! ['', nil].include?(@serveraliases) -%>
<%= " ServerAlias #{@serveraliases}" %> <%= " ServerAlias #{@serveraliases}" %>
<% end -%> <% end -%>
RewriteEngine On RewriteEngine On

View File

@ -7,7 +7,7 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %>
ServerName <%= @srvname %> ServerName <%= @srvname %>
<% if @serveraliases.is_a? Array -%> <% if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != '' -%> <% elsif ! ['', nil].include?(@serveraliases) -%>
<%= " ServerAlias #{@serveraliases}" %> <%= " ServerAlias #{@serveraliases}" %>
<% end -%> <% end -%>
DocumentRoot <%= @docroot %> DocumentRoot <%= @docroot %>

View File

@ -7,7 +7,7 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %>
ServerName <%= @srvname %> ServerName <%= @srvname %>
<% if @serveraliases.is_a? Array -%> <% if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
<% elsif @serveraliases != '' -%> <% elsif ! ['', nil].include?(@serveraliases) -%>
<%= " ServerAlias #{@serveraliases}" %> <%= " ServerAlias #{@serveraliases}" %>
<% end -%> <% end -%>