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
mailman::site class 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 20:13:59 +02:00
parent 48e2a75fb2
commit 9cbaded7dc
1 changed files with 6 additions and 6 deletions

View File

@ -1,13 +1,13 @@
<VirtualHost *:80>
ServerName <%= @default_url_host %>
ServerName <%= scope.lookupvar('::mailman::site::default_url_host') %>
ErrorLog ${APACHE_LOG_DIR}/<%= @default_url_host %>-error.log
ErrorLog ${APACHE_LOG_DIR}/<%= scope.lookupvar('::mailman::site::default_url_host') %>-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/<%= @default_url_host %>-access.log combined
CustomLog ${APACHE_LOG_DIR}/<%= scope.lookupvar('::mailman::site::default_url_host') %>-access.log combined
DocumentRoot /var/www
@ -17,7 +17,7 @@ RewriteRule ^/$ /cgi-bin/mailman/listinfo [R]
# We can find mailman here:
ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/
# And the public archives:
Alias /pipermail/ /srv/mailman/<%= @mailman_site_name %>/archives/public/
Alias /pipermail/ /srv/mailman/<%= scope.lookupvar('::mailman::site::mailman_site_name') %>/archives/public/
# Logos:
Alias /images/mailman/ /usr/share/images/mailman/
@ -34,14 +34,14 @@ Alias /images/mailman/ /usr/share/images/mailman/
AllowOverride None
Options ExecCGI
AddHandler cgi-script .cgi
SetEnv MAILMAN_SITE_DIR /srv/mailman/<%= @mailman_site_name %>
SetEnv MAILMAN_SITE_DIR /srv/mailman/<%= scope.lookupvar('::mailman::site::mailman_site_name') %>
Order allow,deny
Allow from all
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
<Directory /srv/mailman/<%= @mailman_site_name %>/archives/public/>
<Directory /srv/mailman/<%= scope.lookupvar('::mailman::site::mailman_site_name') %>/archives/public/>
Options FollowSymlinks
AllowOverride None
Order allow,deny