Ask Your Question
1

How to correctly look up a fact in a template?

asked 2013-09-01 00:51:17 -0500

Which is more correct when looking up a fact (::is_pe) inside an ERB template?

<% if @is_pe == 'true' %>

or

<% if scope.lookupvar('::is_pe') == 'true' %>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-09-01 02:10:24 -0500

Ancillas gravatar image

If you're using ::ispe, then it's out of scope of your module, and you should use the latter approach (scope.lookupvar). If ispe is in scope (defined in your module), then use the former examle (@is_pe).

edit flag offensive delete link more

Comments

1

Referencing Variables seems to imply that ::is_pe will be available as @is_pe. I also remember a conversation on #puppet that said that a fact value (::is_pe) will always override a ...(more)

razorsedge gravatar imagerazorsedge ( 2013-09-01 15:11:40 -0500 )edit
1

"This can also be used to ensure that you are getting the top-scope value of a variable that may have been overridden in a local scope:". Local scope takes precedence ...(more)

Ancillas gravatar imageAncillas ( 2013-09-01 23:08:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-09-01 00:51:17 -0500

Seen: 2,041 times

Last updated: Sep 01 '13