qualified variables in templates

175 views
Skip to first unread message

Arnau Bria

unread,
Sep 20, 2011, 5:06:07 AM9/20/11
to puppet...@googlegroups.com
Hi all,

is there a way for qualifying variables inside a template?
I've tried :

Name = <%= "${::hostname}" %>

but the var gets "${::hostname}" value.

thinking in version 2.8, is it needed?
http://docs.puppetlabs.com/guides/scope_and_puppet.html says nothing
about this...


TIA,
Arnau

Alessandro Franceschi

unread,
Sep 20, 2011, 2:53:35 PM9/20/11
to Puppet Users
Use something like <%= scope.lookupvar('hostname') %>

On Sep 20, 11:06 am, Arnau Bria <arnaub...@pic.es> wrote:
> Hi all,
>
> is there a way for qualifying variables inside a template?
> I've tried :
>
> Name = <%= "${::hostname}" %>
>
> but the var gets "${::hostname}" value.
>
> thinking in version 2.8, is it needed?http://docs.puppetlabs.com/guides/scope_and_puppet.htmlsays nothing
> about this...
>
> TIA,
> Arnau

Adrien Thebo

unread,
Sep 20, 2011, 2:54:57 PM9/20/11
to puppet...@googlegroups.com
There's also more documentation on using puppet specific methods in templates at http://docs.puppetlabs.com/guides/templating.html

> about this...
>
> TIA,
> Arnau

--
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.




--
Adrien Thebo
Puppet Labs Operations

Arnau Bria

unread,
Sep 21, 2011, 8:53:17 AM9/21/11
to puppet...@googlegroups.com
Ok.
so template and class share the scope and tehre's no need to qualify its vars.

Thanks for your replies and for the link.
Cheers,
Arnau

david boldt

unread,
Jul 13, 2012, 3:46:05 PM7/13/12
to puppet...@googlegroups.com

what is the incantation that would work for iteration?

scope.lookupvar('::varname').each

Produces puppet error:  undefined method `each' for :undefined:Symbol

Felix Frank

unread,
Jul 17, 2012, 12:10:16 PM7/17/12
to puppet...@googlegroups.com
Hi,

On 07/13/2012 09:46 PM, david boldt wrote:
> what is the incantation that would work for iteration?
>
> scope.lookupvar('::varname').each

this looks all right but

> Produces puppet error: undefined method `each' for :undefined:Symbol

it seems that the lookup itself fails. Are you certain you've got the
right name, and that the variable is defined in your context?

It may also be more readable to do

myvar = scope.lookupvar('::varname')
myvar.each do ...

HTH,
Felix
Reply all
Reply to author
Forward
0 new messages