I think this will work, but I don't have a machine to test the syntax on right now:
include repositories
Package {
ensure => latest,
require => Class['repositories'],
}
class repositories {
case $operatingsystem {
debian: {
$repositoryclass
}
fedora: {
$repositoryclass
}
default: {
fail "Unsupported OS $operatingsystem'"
}
}
require( Class[ $repositoryclass ] )
}
> Is there any way for a class to depend on another class or for the
> include statement to act more like a require?
Two things here:
If you're on 2.6.3 put your repositories class in a 'pre' stage, that way you eliminate putting an individual dependency on every package resource as you're currently doing.
Minimally in your current code change 'include repositories::debian' to 'require("repositories::debian")' - this is a built-in function that does an include-plus-require and will produce the ordering you want (Thanks to Jeff Mccune for pointing me at this) http://docs.puppetlabs.com/references/latest/function.html#require
- Eric Sorenson - N37 17.255 W121 55.738 - http://twitter.com/ahpook -
Unfortunately I'm still stuck in 0.25 land. Staging looks like a nicer
solution to some of my problems.
> Minimally in your current code change 'include repositories::debian' to 'require("repositories::debian")' - this is a built-in function that does an include-plus-require and will produce the ordering you want (Thanks to Jeff Mccune for pointing me at this) http://docs.puppetlabs.com/references/latest/function.html#require
require was the function I was looking for. So obvious and documented.
Thank you,
Dan
It appears that I was a little too early in my celebration.
"require $class" causes you to import the class, however no dependency
is then placed on the *contents* of said class. I'm in exactly the same
position. If I have "require => Class[repository::fedora]" instead of
just "require => Class[repository]" in the Package definition I get the
results desired. This strikes me as a design flaw.
I tried the puppet 2.6.3 gem but it still performs in the same fashion.
I'll try generating some simplified configs in a test environment and
file a bug report. Then I'll redesign everything else.
Dan
It sounds like you don't have a relationship defined between
Class[repository] and Class[repository::fedora] ?
Setting up a relationship with the former does not imply a
relationship with the latter.
>
> I tried the puppet 2.6.3 gem but it still performs in the same fashion.
>
> I'll try generating some simplified configs in a test environment and
> file a bug report. Then I'll redesign everything else.
>
> Dan
>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>
--
Nigel Kersten - Puppet Labs - http://www.puppetlabs.com
class repository contains a "require repository::fedora" line (context
has been lost from the first mail)
> Setting up a relationship with the former does not imply a
> relationship with the latter.
I've tracked it down to being a problem with 0.25.5. Using 2.6.3 the
require gets expanded correctly. Either solution I need to upgrade to 2.6.3.
I was previously calling puppetd which is not maintained by the 2.6.3
gem, so I was not actually testing 2.6.3. "puppet agent --test --noop"
works.
I now have large expanded_relationships graph with yum repos at the top
and a long line of Packages below.
Dan
That's really good to know Daniel. Thanks for that.
>
> I was previously calling puppetd which is not maintained by the 2.6.3
> gem, so I was not actually testing 2.6.3. "puppet agent --test --noop"
> works.
>
> I now have large expanded_relationships graph with yum repos at the top
> and a long line of Packages below.
>
> Dan
>