From b54344129dff755fd88ccf40e75a8de0c7f62e2d Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Thu, 12 Jul 2018 09:41:44 +0200 Subject: [PATCH] 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 --- modules/openstack_project/templates/legacy.vhost.erb | 2 +- modules/openstack_project/templates/static-governance.vhost.erb | 2 +- .../openstack_project/templates/static-http-and-https.vhost.erb | 2 +- .../openstack_project/templates/static-https-redirect.vhost.erb | 2 +- modules/openstack_project/templates/status.vhost.erb | 2 +- modules/openstack_project/templates/summit.vhost.erb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/openstack_project/templates/legacy.vhost.erb b/modules/openstack_project/templates/legacy.vhost.erb index 352a795501..579e935f83 100644 --- a/modules/openstack_project/templates/legacy.vhost.erb +++ b/modules/openstack_project/templates/legacy.vhost.erb @@ -7,7 +7,7 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %> ServerName <%= @srvname %> <% if @serveraliases.is_a? Array -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> -<% elsif @serveraliases != '' -%> +<% elsif ! ['', nil].include?(@serveraliases) -%> <%= " ServerAlias #{@serveraliases}" %> <% end -%> diff --git a/modules/openstack_project/templates/static-governance.vhost.erb b/modules/openstack_project/templates/static-governance.vhost.erb index dd3637291b..3b6a57c6a2 100644 --- a/modules/openstack_project/templates/static-governance.vhost.erb +++ b/modules/openstack_project/templates/static-governance.vhost.erb @@ -6,7 +6,7 @@ ServerName <%= @vhost_name %> <% if @serveraliases.is_a? Array -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> -<% elsif @serveraliases != '' -%> +<% elsif ! ['', nil].include?(@serveraliases) -%> <%= " ServerAlias #{@serveraliases}" %> <% end -%> RewriteEngine On diff --git a/modules/openstack_project/templates/static-http-and-https.vhost.erb b/modules/openstack_project/templates/static-http-and-https.vhost.erb index a82bd24b9f..e29fbabe0c 100644 --- a/modules/openstack_project/templates/static-http-and-https.vhost.erb +++ b/modules/openstack_project/templates/static-http-and-https.vhost.erb @@ -7,7 +7,7 @@ <% if @serveraliases.is_a? Array -%> # Permanently redirect these ServerAlias entries to ServerName <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> -<% elsif @serveraliases != '' -%> +<% elsif ! ['', nil].include?(@serveraliases) -%> <%= " ServerAlias #{@serveraliases}" %> RewriteEngine On RewriteCond %{HTTP_HOST} !<%= @vhost_name %>$ [NC] diff --git a/modules/openstack_project/templates/static-https-redirect.vhost.erb b/modules/openstack_project/templates/static-https-redirect.vhost.erb index f77b59464a..3ae6dd1147 100644 --- a/modules/openstack_project/templates/static-https-redirect.vhost.erb +++ b/modules/openstack_project/templates/static-https-redirect.vhost.erb @@ -6,7 +6,7 @@ ServerName <%= @vhost_name %> <% if @serveraliases.is_a? Array -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> -<% elsif @serveraliases != '' -%> +<% elsif ! ['', nil].include?(@serveraliases) -%> <%= " ServerAlias #{@serveraliases}" %> <% end -%> RewriteEngine On diff --git a/modules/openstack_project/templates/status.vhost.erb b/modules/openstack_project/templates/status.vhost.erb index e668353c43..481db90071 100644 --- a/modules/openstack_project/templates/status.vhost.erb +++ b/modules/openstack_project/templates/status.vhost.erb @@ -7,7 +7,7 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %> ServerName <%= @srvname %> <% if @serveraliases.is_a? Array -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> -<% elsif @serveraliases != '' -%> +<% elsif ! ['', nil].include?(@serveraliases) -%> <%= " ServerAlias #{@serveraliases}" %> <% end -%> DocumentRoot <%= @docroot %> diff --git a/modules/openstack_project/templates/summit.vhost.erb b/modules/openstack_project/templates/summit.vhost.erb index d5b4f5f923..29963ac5e3 100644 --- a/modules/openstack_project/templates/summit.vhost.erb +++ b/modules/openstack_project/templates/summit.vhost.erb @@ -7,7 +7,7 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %> ServerName <%= @srvname %> <% if @serveraliases.is_a? Array -%> <% @serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> -<% elsif @serveraliases != '' -%> +<% elsif ! ['', nil].include?(@serveraliases) -%> <%= " ServerAlias #{@serveraliases}" %> <% end -%>