Brady Catherman
2010-Feb-22 23:53 UTC
[Puppet Users] erb getting the default value of a define
I have a define that sets a bunch of default values: define virtualhost($vhostname, $vhost_template, ... , $ssl_enabled = false) { if $ssl_enabled == true { $extension = ''-ssl'' } else { $extension = '''' } file { "/etc/httpd/sites-available/${vhostname}${extension}.conf": ensure => present, content => template($vhost_template), mode => 0644; in the template I have a line: # <%= ssl_enabled %> and the specific definition is: apache::virtualhost { "$title.local.twitter.com-ssl": vhostname => "$title.local.twitter.com", vhost_template => "twitter/staging.local.twitter.com.conf.erb", ssl_enabled => true; the file is named with -ssl, but the contents of the file (produced with erb) produces a line: # false So the contents of the define() see ssl_enabled properly, but the erb doesn''t. Is this known? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Brady Catherman
2010-Feb-23 00:21 UTC
Re: [Puppet Users] erb getting the default value of a define
I actually just figured out a big part of this. I have two definitions: apache::virtualhost { "$title.local.twitter.com": vhostname => "$title.local.twitter.com", vhost_template => "twitter/staging.local.twitter.com.conf.erb"; } apache::virtualhost { "$title.local.twitter.com-ssl": vhostname => "$title.local.twitter.com", ssl_enabled => true, vhost_template => "twitter/staging.local.twitter.com.conf.erb"; } The defaults from the first definition are used in both file deliveries as though its only parsing the template once then is caching the results, even though variables are changing that make the template different. If I comment out the first block the second block works as expected. If I reverse them then the second block gets overwritten by the first, regardless of which comes first. This seems like a bug to me. Is this a known thing or should I try to reproduce on a smaller scale? On Feb 22, 2010, at 3:53 PM, Brady Catherman wrote:> I have a define that sets a bunch of default values: > > define virtualhost($vhostname, $vhost_template, ... , $ssl_enabled > = false) { > if $ssl_enabled == true { > $extension = ''-ssl'' > } else { > $extension = '''' > } > > file { > "/etc/httpd/sites-available/${vhostname}${extension}.conf": > ensure => present, > content => template($vhost_template), > mode => 0644; > > > in the template I have a line: > # <%= ssl_enabled %> > > and the specific definition is: > apache::virtualhost { > "$title.local.twitter.com-ssl": > vhostname => "$title.local.twitter.com", > vhost_template => "twitter/staging.local.twitter.com.conf.erb", > ssl_enabled => true; > > > the file is named with -ssl, but the contents of the file (produced > with erb) produces a line: > # false > > So the contents of the define() see ssl_enabled properly, but the > erb doesn''t. Is this known? > > -- > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com > . > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en > . >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.