On 04/15/2011 09:10 PM, Clay Caviness wrote:
> Let's say I have a very simple template
> template.erb:
> <% if not has_variable?("foobar") then foobar = "undefined" end -%>
> foobar: <%= foobar %>
> class: <%= foobar.class %>
>
> And a basic manifest:
> template.pp:
> $mytemp = template('template.erb')
> notice($mytemp)
>
> And then I apply the manifest, with an undefined foobar (no foobar fact):
> $ puppet apply ~/template.pp
> notice: Scope(Class[main]): foobar: undefined
> class: String
>
> notice: Finished catalog run in 0.01 seconds
>
> Looking good. So now I apply the manifest, but with a defined value
> for foobar (via the FACTER_FOOBAR environment variable):
> $ FACTER_FOOBAR='foo' puppet apply ~/template.pp
> notice: Scope(Class[main]): foobar:
> class: NilClass
>
> notice: Finished catalog run in 0.01 seconds
>
> Er, what? How on earth did foobar go from a String to NilClass? I
> can't fathom how this is expected, or correct...
>
> The reason I was doing this sort of thing is to give a possibly
> missing fact a default value. I ended up using a second variable, like
> this:
> <% foo = has_variable?("foobar") ? foobar.to_s : "false" -%>
>
Hi,
does this work better if you set $foobar in your manifest?
Looks like a bug you may want to report either way.
Regards,
Felix
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" 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-users?hl=en.