Hello puppet masters, I am cleaning up some puppet modules, using
puppet-lint. The warning I am getting is:
top-scope variable being used without an explicit namespace
I can turn this particular check off, but in doing my research I'm
finding all sorts of messages saying to avoid using +=, to avoid using
variables in the node scope, and to switch to a parameterized class
whenever possible. Okay, I'm game.
So, to understand what I'm doing, I'm setting up a yum repository and
limiting the includepkgs line to the very minimum amount of packages for
reasons of security / policy / insanity / etc.
Here is the current implementation of this (which works fine).
node standard {
$epel_includepkgs += 'puppet augeas-libs facter ruby-augeas ruby-shadow '
class { 'repo_epel': stage => 'pre' }
#other stuff
}
node 'my.node1' inherits standard {
include denyhosts
}
node 'my.node2' inherits standard {
include denyhosts
include gitlabhq
}
class repo_epel {
yumrepo { 'epel':
enabled => 1,
descr => 'Extra Packages for Enterprise Linux 6 -
\$basearch',
mirrorlist =>
'https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch',
failovermethod => priority,
gpgcheck => 1,
gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6',
require => File['/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6'],
includepkgs => $epel_includepkgs,
}
# other stuff
}
class denyhosts {
$epel_includepkgs += 'denyhosts '
# other stuff
}
class gitlabhq {
$epel_includepkgs += 'libyaml gitolite git-all rvm '
# other stuff
}
my.node1, and my.node2 will have different (and correct) includepkgs
doing it this way (I have like .. 30+ modules for epel and more of other
repos to give you an idea)
To get rid of the error I tried making the variable $::epel_includepkgs,
but that generates the error:
err: Could not parse for environment production: Cannot assign to
variables in other #namespaces
So what is the 'proper' puppet way to accomplish this?
I tried a parameterized class like this:
class repo_epel ($include_pkgs) {
notify { "include_pkgs = $include_pkgs":}
}
class denyhosts {
$repo_epel::include_pkgs += "denyhosts "
}
but from what I understand that only changes the include_pkgs variable
inside the denyhosts scope (or maybe I'm confused).
Any help would be appreciated.
Thanks
--
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.