I'm having a really hard time grasping how variables are scoped in
puppet (not really much of a programmer).
I've got a manifest that looks like this:
###
class puppet::config {
include puppet::params
file { '/etc/puppet/puppet.conf':
ensure => present,
content => template('puppet/puppet.conf.erb'),
owner => 'root',
group => 'admins',
require => Class['puppet::install'],
notify => Class['puppet::service'],
}
}
###
I've then got a manifest like this, which has a class being included above:
###
class puppet::params {
$puppetserver = 'command.enterawesome.com'
}
###
The template being used in the first class includes the variable
$puppetserver, but somehow, the include statement isn't enough for the
variable to be defined within the scope of the manifest/template
above.
What gives?
It works just fine if I include a statement like this in the erb file:
<%= scope.lookupvar('puppet::params::puppetserver') %>
But I'd really like to understand scoping better. What is it I need to
do to just refer to the variable by name? Why isn't the include
statement enough? Isn't in including the puppet::params class inside
the puppet::config class, and therefore having the variable defined in
that context? Apparently not. But I don't understand why. I wan't to
end up at a point where the variable is in the proper scope, such that
I can just have a statement like <%= puppetserver %> inside of the
template I'm using.
Thanks in advance!
--
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.