-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The issue is that, should you call that define more than once, there's no way 
for Puppet to know which one to use unless it walks directly up the call
stack first.

Trevor

On 12/28/2011 09:16 PM, Ryan Coleman wrote:
> 
> 
> On Monday, December 26, 2011 5:56:26 AM UTC-8, Trevor Vaughan wrote:
>>
>> I just ran into an interesting scenario where I didn't know how to
>> scope my variables and I'd just like to share for the crowd.
>>
>> Suppose you have two modules 'foo' and 'bar'. You also have two
>> defines, 'foo::do_stuff' and 'bar::more_stuff'.
>>
>> define foo::do_stuff (
>>   $var1 = 'a',
>>   $var2 = 'b'
>> ) {
>>   bar::more_stuff { 'test': }
>> }
>>
>> define bar::more_stuff (
>>   $optional_var = 'ignore'
>> ) {
>>   file { '/tmp/test':
>>     content => template('bar/random.erb')
>> }
>>
>> +++ random.erb +++
>>
>> var1 = <%= var1 %>
>> var2 = <%= var2 %>
>>
> Have you tried this in your template?
> 
> <%= scope.lookupvar('foo::do_stuff::var1') %>
> 
> That should let you refer directly to the variable in that define, if I 
> understand your setup correctly.
> 

- -- 
Trevor Vaughan
 Vice President, Onyx Point, Inc.
 email: tvaug...@onyxpoint.com
 phone: 410-541-ONYX (6699)
 pgp: 0x6C701E94

- -- This account not approved for unencrypted sensitive information --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJO/HDxAAoJECNCGV1OLcypqScIAIlaCSNBRncSh4/1zGXyuvX5
CA35+lpr4TaQ8JweGltLmY0Ceb3RQcLyiqXdna3pZ1+kLNiKnrlysaRk6/e91zO7
0ngbhMGbOJLK0TyHFPq+5m+VjB0DvEvCaNRYIabQZWOwVKRLCpQYaFOoQPLyZ3f2
JX3YsvdhqhreVxqFKv7SlStc1cLxSoh8+TjWTwxQsa9Sq6Ff9P+iY+zTyHbZU7IP
opBLbg1uIS1xIYSYILZKtkDvQjAVfY8oYvmslz0MXKyS6TTZMVYGs8F8zJUZSpC8
lO8LEAyLtXsPIAGKNevfKpka3KxZ2wQ7mM70ydK3ShPEYe77V9K/oXBGeg2dh7E=
=/Fg0
-----END PGP SIGNATURE-----

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

<<attachment: tvaughan.vcf>>

Reply via email to