Issue #8707 has been updated by Andrew Parker. Status changed from Accepted to Closed
This was fixed in puppet 3 ---------------------------------------- Bug #8707: Scope.lookupvar() returns undef perhaps should return nil https://projects.puppetlabs.com/issues/8707#change-82524 Author: Karl Pietri Status: Closed Priority: Normal Assignee: Category: templates Target version: Affected Puppet version: 2.7.10 Keywords: Branch: When in a erb template in puppet if you use scope.lookupvar() with a variable that doesn't exist you get a return value of the label undefined (:undefined) this breaks being able to do this: <% if scope.lookupvar("::ipadress_eth2") %>i have an eth2 <% end %> Examples: err(inline_template('testing truth: <% if scope.lookupvar("::ipaddress_eth1") %>has ip: <%= scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>')) err(inline_template('testing undefined str: <% if scope.lookupvar("::ipaddress_eth1")!="undefined" %>has ip: <%= scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>')) err(inline_template('testing undefined label: <% if scope.lookupvar("::ipaddress_eth1")!=:undefined %>has ip: <%= scope.lookupvar("::ipaddress_eth1") %><% else %>has no ip<% end %>')) output: Jul 29 12:10:29 monitor1.example.com puppet-master[533]: (Scope(Class[Shared::Sshd])) testing truth: has ip: undefined Jul 29 12:10:29 monitor1.example.com puppet-master[533]: (Scope(Class[Shared::Sshd])) testing undefined str: has ip: undefined Jul 29 12:10:29 monitor1.example.com puppet-master[533]: (Scope(Class[Shared::Sshd])) testing undefined label: has no ip Perhaps the function should return nil instead of :undefined to prevent confusion -karl PS not sure if this is a bug or a feature request -- 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.
