Fix scope of vhost template variables

Dynamic scoping for variables in ERB templates was removed in puppet
4[1] which means that the variables defined in the
manifest cannot be found when it is referenced in
the httpd::vhost defined type and will be evaluated as nil when
puppet runs. Use scope.lookupvar instead to be explicit about the
variable's source.

[1] https://puppet.com/docs/puppet/4.10/lang_updating_manifests.html#dynamic-scoping-in-erb

Change-Id: Ifc1db7851d2a0cd39af9f05b55ec9a546a12f567
This commit is contained in:
Colleen Murphy 2018-04-27 22:44:03 +02:00
parent e4901f6217
commit 1de34a782d
1 changed files with 6 additions and 6 deletions

View File

@ -5,7 +5,7 @@
NameVirtualHost <%= @vhost_name %>:80
<VirtualHost <%= @vhost_name %>:80>
<% if @site_ssl_enabled %>
<% if scope.lookupvar('::drupal::site_ssl_enabled') %>
ServerName <%= @srvname %>
Redirect / https://<%= @srvname %>/
</VirtualHost>
@ -14,10 +14,10 @@ NameVirtualHost <%= @vhost_name %>:443
<VirtualHost <%= @vhost_name %>:443>
SSLEngine on
SSLProtocol All -SSLv2 -SSLv3
SSLCertificateFile <%= @site_ssl_cert_file %>
SSLCertificateKeyFile <%= @site_ssl_key_file %>
<% if @site_ssl_chain_file_contents %>
SSLCertificateChainFile <%= @site_ssl_chain_file %>
SSLCertificateFile <%= scope.lookupvar('::drupal::site_ssl_cert_file') %>
SSLCertificateKeyFile <%= scope.lookupvar('::drupal::site_ssl_key_file') %>
<% if scope.lookupvar('::drupal::site_ssl_chain_file_contents') %>
SSLCertificateChainFile <%= scope.lookupvar('::drupal::site_ssl_chain_file') %>
<% end %>
<% end %>
ServerName <%= @srvname %>
@ -30,7 +30,7 @@ NameVirtualHost <%= @vhost_name %>:443
<Directory <%= @docroot %>>
Options FollowSymLinks MultiViews
AllowOverride None
<% if @new_vhost_perms %>
<% if scope.lookupvar('::drupal::new_vhost_perms') %>
Require all granted
<% else %>
Order allow,deny