Hi Lowe,

On Tue, Aug 16, 2016 at 1:31 AM, Lowe Schmidt <m...@loweschmidt.se> wrote:
> What version of Puppet are you running?

Debian Jessie:

3.7.2-4

-m

> --
> Lowe Schmidt | +46 723 867 157
>
> On 15 August 2016 at 20:48, Matt Zagrabelny <mzagr...@d.umn.edu> wrote:
>>
>> Greetings!
>>
>> I am hitting a curious question and couldn't find an answer.
>>
>> I can access variables from other classes when using an erb template.
>>
>> Here is my minimal example:
>>
>> # puppet apply variable_scope_test.pp
>> Notice: Compiled catalog for puppet.example.com in environment
>> production in 0.12 seconds
>> Notice: A variable from a different class:
>> Notice: /Stage[main]/Scope_example::Sub_class/Notify[A variable from a
>> different class: ]/message: defined 'message' as 'A variable from a
>> different class: '
>> Notice: Finished catalog run in 0.11 seconds
>>
>> # cd /tmp
>> # head -n -0 variable_scope_test.pp template.erb template_output
>> ==> variable_scope_test.pp <==
>> class scope_example {
>>     $variable = "THIS IS A TEST!"
>>     include scope_example::sub_class
>> }
>>
>> class scope_example::sub_class {
>>     file { '/tmp/template_output':
>>         content => template('/tmp/template.erb'),
>>     }
>>     notify { "A variable from a different class: $variable": }
>> }
>>
>> node 'puppet.example.com' {
>>     include scope_example
>> }
>>
>> ==> template.erb <==
>> <%= @variable %>
>>
>> ==> template_output <==
>> THIS IS A TEST!
>>
>> So why is the template allowed to see variables in other classes?
>>
>> I would have ad expected to need to use the variable like:
>>
>> <%= @scope_example::variable %>
>>
>> But it clearly works without adjusting its namespace.
>>
>> Thoughts?
>>
>> Thanks!
>>
>> -m
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to puppet-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/CAOLfK3WBY9Hg%3DsaiHA2iAt4SRQjBX6XLsAJVj_qLGHJgjuugEg%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAC-wWcSmcHxSC5h169UOBiqq0HJTRtN7C4WfRbmnW02rHgx_OA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOLfK3XcZQ3ck7ZN8BWf27OT8Oc-suk-hBXZ01v1uXLANQoxGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to