Puppet class dependency management

asked 2018-08-27 23:01:27 -0600

Suppose I have a class that installs packages(profile::base::tools) and another class that defines the yumrepos(profile::base::yum) required for those packages.

tools.pp:

class profile::base::tools {
   $packages = [
      'package1',
      'package2'
   ]

   package { $packages:
     ensure => present,
   }
}

Currently the way it is run is through base.pp:

base.pp:

include profile::base::yum 
include profile::base::tools

Class['profile::base::yum'] -> [
    Class['profile::base::tools']]

So when I run base.pp it creates the yum repos first and then installs the packages. Currently the dependency that the tools.pp requires yumrepos defined first is only mentioned in the base.pp. My question is if i run tools.pp alone(for testing purposes) it wont know about the dependency and hence fail. I can add include profile::base::yum in the tools.pp class but wanted to know if its a standard for each class to know about dependencies even if its already defined elsewhere(like in base.pp).

edit retag flag offensive close merge delete