When defining dependencies in a class each Package
can be globally defined just once. I have hierarchy of configuration and some packages should be installed on all machines (that goes to default configuration) but other should be installed only on some category of machines. How I am supposed to check whether that package is already on a machine when Puppet threat is as a duplicate declaration?
Duplicate declaration: Package[wget] is already declared
should I use a function like this?
if defined( Package[$package] ) {
debug("$package already installed")
} else {
package { $package: ensure => $ensure }
}
I would expect from configuration tool to deal whith this issue by default… am I missing something?
Best Answer
You can use the ensure_resource() from stdlib module:
So, say, if git is installed by some other class already, that would be skipped. You should not care of defining a package only once throughout the puppet configuration.