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: I8d2b351537ad8fc0a06c58e1dd23d8423f38a328
This commit is contained in:
Colleen Murphy 2018-04-27 22:49:35 +02:00
parent 31e44bbcb0
commit 281acd62ab
1 changed files with 8 additions and 7 deletions

View File

@ -38,20 +38,21 @@
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
<% if @auth_openid != nil %>
<% auth_openid = scope["ethercalc::apache::auth_openid"] %>
<% if ! [nil, :undef].include?(auth_openid) %>
<Location />
AuthType OpenID
AuthName "<%= @auth_openid['banner'] %>"
AuthName "<%= auth_openid['banner'] %>"
AuthOpenIDSecureCookie On
AuthOpenIDCookieLifespan 3600
AuthOpenIDTrustRoot https://<%= scope.lookupvar("ethercalc::apache::vhost_name") %>
AuthOpenIDServerName https://<%= scope.lookupvar("ethercalc::apache::vhost_name") %>
AuthOpenIDSingleIdP <%= @auth_openid['singleIdp'] %>
AuthOpenIDTrusted <%= @auth_openid['trusted'] %>
<% if @auth_openid['any_valid_user'] %>
AuthOpenIDSingleIdP <%= auth_openid['singleIdp'] %>
AuthOpenIDTrusted <%= auth_openid['trusted'] %>
<% if auth_openid['any_valid_user'] %>
Require valid-user
<% elsif !@auth_openid['users'].empty? %>
<% @auth_openid['users'].each do |user| -%>
<% elsif !auth_openid['users'].empty? %>
<% auth_openid['users'].each do |user| -%>
Require user <%= user %>
<% end -%>
<% end %>