I'm starting to play with the latest puppet 2.7.0rc4, one of my goals
being to try and update all of my puppet related files to be compatible
with it, with no warnings at all.
I've read in detail this page :
http://docs.puppetlabs.com/guides/scope_and_puppet.html
There is no mention of anything special to do for global scope
variables inside templates, such as :
file { '/tmp/test': content => inline_template ('<%= fqdn %>') }
Yet when using <%= ::fqdn %> I get the following :
(err): compile error
(erb):1: syntax error, unexpected tIDENTIFIER, expecting tCONSTANT
_erbout = ''; _erbout.concat(( ::fqdn ).to_s); _erbout
How should these global scope variables (facts in this case) be used
inside erb templates? Maybe there's some obvious ruby syntax I'm
missing?
Matthias
inline_template('<%= scope.lookupvar("::fqdn") %>')
ken.
On Sun, Jun 12, 2011 at 3:20 PM, Matthias Saou
<th...@spam.spam.spam.spam.spam.spam.spam.egg.and.spam.freshrpms.net>
wrote:
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>
Thanks, using scope.lookupvar() in the templates does work. But will
this be the proper way to echo facts in puppet 2.7 and 2.8? Because it
does seem like quite an extra burden, and if it's not really decided
yet, I prefer sticking with the warnings for now ;-)
Matthias
Then I'm guessing the only other solution, which also works with 0.25
and any higher version would be :
$local_scope_fqdn = $::fqdn
Then :
<%= local_scope_fqdn %>
In order to use a local scope variable from within templates.
It's really too bad to not be able to use scoped variables from erb
templates directly, as it won't ever be as convenient as before for
facts and global scope variables.
Matthias