Issue #10505 has been updated by Andrew Parker.

Status changed from Investigating to Rejected
Assignee deleted (Daniel Pittman)

As tracked in #19058 we are deprecating the method call syntax for getting 
access to scope variables. This is because of this and many other issues 
related to the use of this syntax. Therefore this issue will not be fixed.
----------------------------------------
Bug #10505: erb mangles if foo == "" and leaves variables undefined
https://projects.puppetlabs.com/issues/10505#change-82559

Author: Jos Boumans
Status: Rejected
Priority: High
Assignee: 
Category: templates
Target version: 
Affected Puppet version: 2.6.3
Keywords: 
Branch: 


<pre>
$ puppet --version
2.6.3
</pre>

<pre>
$ cat x.pp
define bar ( $foo = "", $zot = "" ) {
  file { '/mnt/tmp/puppet.erb/out':
    content => template( '/mnt/tmp/puppet.erb/tmpl.erb' ),
    ensure => file,
  }
}

bar { $fqdn: foo => "42", zot => "43" }
$ cat tmpl.erb 

foo 1: <%= foo %>
zot 1: <%= zot %>

<% if foo == "" %>
<% foo = 1 %>
<% end %>

foo 2: <%= foo %>
zot 2: <%= zot %>
$ puppet x.pp
notice: /Stage[main]//Bar[cc001.krxd.net]/File[/mnt/tmp/puppet.erb/out]/ensure: 
defined content as '{md5}c776b25cce50fdc968696030b77e9a4d'
$ cat out

foo 1: 42
zot 1: 43



foo 2: 
zot 2: 43
</pre>

################

Confirmed also in 2.7.x, the work around is:
<% foo = scope.lookupvar('foo') || '1' %>



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to