On Nov 18, 9:03 am, Theo Cabrerizo Diem <d...@carpediem.sh> wrote:
[...]
>
> define foo ($myparam = "Hello") {
>   notice(inline_template("<%= scope.findresource('Foo[${name}]')['myparam']
> %>"))}
>
> node 'default' {
>   foo { 'test1': }
>   foo { 'test2': }
>   foo { 'test3': myparam => "World", }
>
> }
>
> This will produce:
> notice: Scope(Foo[test1]): Hello
> notice: Scope(Foo[test2]): Hello
> notice: Scope(Foo[test3]): World
>
> Which means my problem is accessing the scope where a given instance of a
> resource is located.


Naturally, a template called from inside the defined type's body has
access to the instance's parameter values, including defaulted ones.
Most people would just use them as simple variables, however, rather
than looking them up via the scope object.  In fact, I'm inclined to
call 'bug' on this one: it should never be the case that <%=
scope.findresource('Foo[bar]')['myparam'] %> can be evaluated without
error to return two different values in the same catalog run.

In any case, I don't see why you suppose that the values you want will
remain accessible outside the definition body.  It was worth a try,
certainly, but if the lookup you have already attempted does not do
the job then I can't imagine what would.

> [...]
> I know the code above is useless as it is, but my point is to be able to
> iterate through given resources of a node in a template, allowing great
> flexibility inside a template, without the artifacts that concat module
> generates (and its drawbacks).


I understand why you want to do what you ask, but I just don't think
Puppet supports it.  Feel free to submit a feature request.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to