Hi Ryan,
On 11 Aug 2015, at 19:22, Ryan Whitehurst <[email protected]> wrote:

> 
> Martin Alfke writes:
> 
>> How can I access the variable from the first define? I can change the second 
>> define to have another parameter so it knows about the template variable. Is 
>> there any other solution available?
> It's not exactly the same, but this works now, using EPP instead of ERB: 

Many thanks for pointing to EPP.
We can not yet switch to EPP.
We want our example42 modules to be compatible with puppet 3 and 4 and will do 
a version bump very soon offering new language features..

Besides this:
when I saw this construct (accessing variables from another module(!! sic)) my 
in-brain puppet parser already went nuts.
I decided to add the variable as parameter which makes it now far more clear 
where the value is taken from.

Best,
Martin


> scope_epp/manifests/define1.pp
> 
> ~~~
> define scope_epp::define1 ($var = 'test') {  scope_epp::define2 { $name:    
> epp => 'scope_epp/test.epp',  } }
> ~~~  scope_epp/manifests/define2.pp
> 
> ~~~
> define scope_epp::define2 ($epp) {  notify { $name:    message => epp($epp, 
> {'name' => $name}),  } }
> ~~~  scope_epp/templates/test.epp
> 
> ~~~ <%= Scope_epp::Define1[$name]['var'] %> ~~~
> 
> Then running:
> 
> % /opt/puppetlabs/bin/puppet apply -e 'scope_epp::define1 { "thing": }' 
> --modulepath=.  Notice: Compiled catalog for localhost in environment 
> production in 0.64 seconds Notice: test Notice: 
> /Stage[main]/Main/Scope_epp::Define1[thing]/Scope_epp::Define2[thing]/Notify[thing]/message:
>  defined 'message' as 'test'  You can't use that to access variables from the 
> defined type, but you can access parameters. Now whether you should do that 
> or not…

I prefer to not do that.
;-)

> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-dev/87mvxxspjc.fsf%40rafiki.corp.puppetlabs.net.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/FADBAE25-E21A-4E0F-A0F8-553C070FD1D8%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to