On Thu, Sep 22, 2011 at 01:11:28PM -0700, jcbollinger wrote:
> On Sep 22, 12:54 pm, Robin Lee Powell <[email protected]>
> wrote:
> > On Thu, Sep 22, 2011 at 09:53:46AM -0400, John Morrissey wrote:
> > > I'm using an Apache 2 base class based on
> > >http://projects.puppetlabs.com/projects/1/wiki/Debian_Apache2_Recipe_....
> >
> > > I'd like to pass additional dependencies to the class and/or the
> > > definitions it contains. For example, I'd like to allow classes using
> > > this Apache base class to add additional require items to
> > > Service['apache2'].
[snip]
> > > but this requires apache2 consumers to pass the entire dependency list;
> > > the
> > > apache2 base class can't inject its own dependencies transparently. I'd
> > > like
> > > the passed dependencies to be *in addition to* any dependencies the
> > > apache2
> > > base class demands.
> >
> > I *believe* this will work:
> >
> > class apache2($extra_requires) {
> > service { 'apache2':
> > require => [Service['foo'], $extra_requires],
> > }}
> >
> > class { 'apache2':
> > extra_requires => [Package['foo'], Package['bar']],
> >
> > }
> >
> > But I have not tested it.
>
> I do not know whether that works, but I would not personally feel
> comfortable assuming that it would continue to work from one version
> of Puppet to another.
nod, the semantics that implies sketches me out a little bit.
> I think this is rather a quirky question in the first place.
> Generally one wants to write classes that are fairly self-contained,
> and modules that are as much as possible self-contained. Among other
> things, that implies that classes ought to know their own requirements
> rather than having to be told them.
The base class is self contained, but the depending class has resources that
modify the base class' behavior in such a way that I'd prefer that those
resources be in place before the service resource is processed. I'm probably
nit picking in this case, though.
> A better solution than passing dependencies into a class might be
> class-level dependencies. For example, if you have a Foo resource
> that must be applied before all of the resources of class apache2,
> then declare the dependency from that side via the "before"
> metaparameter:
>
> foo { "my_foo":
> # various properties...
>
> before => Class['apache2']
> # note: that class should be in a module, and
> # referred to by its fully-qualified name
> }
ach, I always forget about 'before'. That'll work just fine. Thanks.
john
--
John Morrissey _o /\ ---- __o
[email protected] _-< \_ / \ ---- < \,
www.horde.net/ __(_)/_(_)________/ \_______(_) /_(_)__
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.