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 the manifests 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: I344be46a2e69d0eadda9148e1b7dd1f73c7a1edd
This commit is contained in:
Colleen Murphy
2018-04-27 21:10:11 +02:00
parent 7abbdafc62
commit e0f2afc800

View File

@@ -10,7 +10,7 @@ WSGIRestrictSignal Off
NameVirtualHost <%= @vhost_name %>:80 NameVirtualHost <%= @vhost_name %>:80
<VirtualHost <%= @vhost_name %>:80> <VirtualHost <%= @vhost_name %>:80>
<% if @site_ssl_enabled %> <% if scope.lookupvar('::askbot::config::site_ssl_enabled') %>
ServerName <%= @srvname %> ServerName <%= @srvname %>
Redirect / https://<%= @srvname %>/ Redirect / https://<%= @srvname %>/
</VirtualHost> </VirtualHost>
@@ -19,10 +19,10 @@ NameVirtualHost <%= @vhost_name %>:443
<VirtualHost <%= @vhost_name %>:443> <VirtualHost <%= @vhost_name %>:443>
SSLEngine on SSLEngine on
SSLProtocol All -SSLv2 -SSLv3 SSLProtocol All -SSLv2 -SSLv3
SSLCertificateFile <%= @site_ssl_cert_file %> SSLCertificateFile <%= scope.lookupvar('::askbot::config::site_ssl_cert_file') %>
SSLCertificateKeyFile <%= @site_ssl_key_file %> SSLCertificateKeyFile <%= scope.lookupvar('::askbot::config::site_ssl_key_file') %>
<% if @site_ssl_chain_file_contents != nil %> <% if scope.lookupvar('::askbot::config::site_ssl_chain_file_contents') != nil %>
SSLCertificateChainFile <%= @site_ssl_chain_file %> SSLCertificateChainFile <%= scope.lookupvar('::askbot::config::site_ssl_chain_file') %>
<% end %> <% end %>
<% end %> <% end %>
ServerName <%= @srvname %> ServerName <%= @srvname %>
@@ -45,7 +45,7 @@ NameVirtualHost <%= @vhost_name %>:443
</Directory> </Directory>
# wsgi daemon # wsgi daemon
WSGIDaemonProcess askbot user=<%= @www_user %> group=<%= @www_group %> maximum-requests=1000 display-name=askbot processes=2 threads=1 shutdown-timeout=10 python-path=<%= @docroot %>:/usr/askbot-env/lib/python2.7/site-packages WSGIDaemonProcess askbot user=<%= scope.lookupvar('::askbot::www_user') %> group=<%= scope.lookupvar('::askbot::www_group') %> maximum-requests=1000 display-name=askbot processes=2 threads=1 shutdown-timeout=10 python-path=<%= @docroot %>:/usr/askbot-env/lib/python2.7/site-packages
WSGIScriptAlias / <%= @docroot %>/config/django.wsgi WSGIScriptAlias / <%= @docroot %>/config/django.wsgi