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 [email protected].
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.