[Puppet Users] Depending on a class from a class?

Daniel Piddock
2010-11-30T15:03:39Z

Hello,

I fear that I have done something stupid in my manifests that requires
a redesign. To take an example:

I have the global statement:
Package {
  ensure  => latest,
  require => Class[''repositories''],
}

I then have a repositories module with init.pp containing:
class repositories {
  case $operatingsystem {
    debian: {
      include repositories::debian
    }
    fedora: {
      include repositories::fedora
    }
    default: {
      fail "Unsupported OS $operatingsystem''"
    }
  }
}

Unfortunately I was hoping that an include here would act like a
requirement, however it does not. The contents of debian.pp/fedora.pp
get evaluated at an arbitrary later point causing interesting issues
when first installing a system. Puppet attempts to install some
packages before the repositories have been configured.

Is there any way for a class to depend on another class or for the
include statement to act more like a require?

In this example it would be trivial to change the global statement to
directly require the operating system''s repositories subclass.
Unfortunately I have used this paradigm in multiple locations, some
where the alternative may not be as obvious or would increase the
verbosity of the including classes.

Thank you for any pointers,