Browse Source

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
Colleen Murphy 1 year ago
parent
commit
281acd62ab
1 changed files with 8 additions and 7 deletions
  1. 8
    7
      templates/ethercalc.vhost.erb

+ 8
- 7
templates/ethercalc.vhost.erb View File

@@ -38,20 +38,21 @@
38 38
   # MSIE 7 and newer should be able to use keepalive
39 39
   BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
40 40
 
41
-  <% if @auth_openid != nil %>
41
+  <% auth_openid = scope["ethercalc::apache::auth_openid"] %>
42
+  <% if ! [nil, :undef].include?(auth_openid) %>
42 43
   <Location />
43 44
       AuthType OpenID
44
-      AuthName "<%= @auth_openid['banner'] %>"
45
+      AuthName "<%= auth_openid['banner'] %>"
45 46
       AuthOpenIDSecureCookie On
46 47
       AuthOpenIDCookieLifespan 3600
47 48
       AuthOpenIDTrustRoot https://<%= scope.lookupvar("ethercalc::apache::vhost_name") %>
48 49
       AuthOpenIDServerName https://<%= scope.lookupvar("ethercalc::apache::vhost_name") %>
49
-      AuthOpenIDSingleIdP <%= @auth_openid['singleIdp'] %>
50
-      AuthOpenIDTrusted <%= @auth_openid['trusted'] %>
51
-      <% if @auth_openid['any_valid_user'] %>
50
+      AuthOpenIDSingleIdP <%= auth_openid['singleIdp'] %>
51
+      AuthOpenIDTrusted <%= auth_openid['trusted'] %>
52
+      <% if auth_openid['any_valid_user'] %>
52 53
       Require valid-user
53
-      <% elsif !@auth_openid['users'].empty? %>
54
-      <% @auth_openid['users'].each do |user| -%>
54
+      <% elsif !auth_openid['users'].empty? %>
55
+      <% auth_openid['users'].each do |user| -%>
55 56
       Require user <%= user %>
56 57
       <% end -%>
57 58
       <% end %>

Loading…
Cancel
Save