On Nov 15, 7:07 am, Falkor <[email protected]> wrote:
> Hi everybody.
>
> i'm running Puppet 2.6.2 and I have the following problem.
>
> Assuming I have a definition toto::tutu instanced as follows:
>
> ------------------%< -------------------
> define toto::tutu ($key = 'default_val') { ... }
>
> toto::tutu { 'example1': key => 'val1' }
> toto::tutu { 'example2': key => 'val2' }
> ------------------------------------------
>
> Is there now a way in another scope (for instance in the definition
> 'tata' to access the value 'val2' for instance?
>
> I was hoping that the syntax
>
> $val = Toto::Tutu['exemple2'][key]
>
> would work but that's not the case. Any suggestion?


To my knowledge, you cannot access variables of a defined type
instance.  I'm not sure they even exist outside the definition.  What
you can do is establish a source of truth outside the definition that
the definition and all other interested parties draw on.  That could
be a variable in some shared lexical scope, a global or class
variable, or external data accessed via extlookup() or hiera.  That
would be a pretty good design strategy even if you were using classes
rather than definitions.


John

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

Reply via email to