Issue #10505 has been updated by Jos Boumans.

Correction, the work around is:
<% foo = scope.lookupvar('foo').length > 0 ? scope.lookupvar('foo') : '1' %>

The other one doesn't work with strings.
----------------------------------------
Bug #10505: erb mangles if foo == "" and leaves variables undefined
https://projects.puppetlabs.com/issues/10505

Author: Jos Boumans
Status: Unreviewed
Priority: High
Assignee: 
Category: templates
Target version: 2.6.x
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to