summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColleen Murphy <colleen@gazlene.net>2018-05-28 14:58:02 -0700
committerColleen Murphy <colleen@gazlene.net>2018-05-28 15:04:15 -0700
commite5996fd2750f2518d175d7bf5cc076d4890f1c23 (patch)
tree1f69a1f66d6c2362ee0173d7c4f3bb390b0d4807
parent9e47c78140da15bc134ffaf7ee5922a78590c4e6 (diff)
Add content parameter to httpd::vhost
Evaluating the template from the vhost defined type rather than the module where it originates causes problems when dereferencing the variables in the ERB file. If they are not accessed via the internal scope object, they can't be found when using puppet 4. The scope object is also useless when the variables are defined in a defined type and not a class. This patch adds a new parameter, $content, which overrides the $template parameter. If provided, $content indicates the literal string content for the vhost, as opposed to a reference to a template that needs to be rendered. This can be used like this: $content = template('example/example.vhost.erb') httpd::vhost { 'vhostname': content => $content, priority => 50 } This way the template is evaluated when the template() function is called and has access to variables in that scope. Change-Id: Ibe3c609d92f3321f43f4794062a64b119b07a1d0
Notes
Notes (review): Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: Ian Wienand <iwienand@redhat.com> Workflow+1: Clark Boylan <cboylan@sapwetik.org> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 21 Jun 2018 20:59:55 +0000 Reviewed-on: https://review.openstack.org/570824 Project: openstack-infra/puppet-httpd Branch: refs/heads/master
-rw-r--r--manifests/vhost.pp10
1 files changed, 9 insertions, 1 deletions
diff --git a/manifests/vhost.pp b/manifests/vhost.pp
index 4a32853..25f30cc 100644
--- a/manifests/vhost.pp
+++ b/manifests/vhost.pp
@@ -10,6 +10,8 @@
10# a firewall should be configured. 10# a firewall should be configured.
11# - The $template option specifies whether to use the default template or 11# - The $template option specifies whether to use the default template or
12# override 12# override
13# - The $content option specifies the exact content of the vhost file;
14# overrides the template parameter
13# - The $priority of the site 15# - The $priority of the site
14# - The $serveraliases of the site 16# - The $serveraliases of the site
15# - The $options for the given vhost 17# - The $options for the given vhost
@@ -41,6 +43,7 @@ define httpd::vhost(
41 $servername = $httpd::params::servername, 43 $servername = $httpd::params::servername,
42 $ssl = $httpd::params::ssl, 44 $ssl = $httpd::params::ssl,
43 $template = $httpd::params::template, 45 $template = $httpd::params::template,
46 $content = undef,
44 $vhost_name = $httpd::params::vhost_name, 47 $vhost_name = $httpd::params::vhost_name,
45 ) { 48 ) {
46 49
@@ -87,9 +90,14 @@ define httpd::vhost(
87 } 90 }
88 } 91 }
89 92
93 if $content != undef {
94 $_content = $content
95 } else {
96 $_content = template($template)
97 }
90 file { "${priority}-${name}.conf": 98 file { "${priority}-${name}.conf":
91 path => "${httpd::params::vdir}/${priority}-${name}.conf", 99 path => "${httpd::params::vdir}/${priority}-${name}.conf",
92 content => template($template), 100 content => $_content,
93 owner => 'root', 101 owner => 'root',
94 group => 'root', 102 group => 'root',
95 mode => '0755', 103 mode => '0755',