On Tue, Sep 28, 2010 at 09:01:25AM -0700, Darren Worrall wrote:
> 
> Is this a bug, or a limitation of class inheritance? (ie, base classes
> are evaluated completely, and subclasses are only allowed to modify
> things after the fact?)
> 
They're not classes, they shouldn't have been called classes, it only
upsets people who understand OO languages and make intelligent
assumptions based on this.  The only things you can really override in a
subclass are properties of resources defined in the superclass.  This is
almost the only thing that class inheritance is useful for (not quite,
but the points are quite subtle and you need to have banged your head on
some of Puppet's walls before you can appreciate them).

Don't set variables to explicit variables inside a class unless you
really know what you are doing.  For the most part, set variables at
manifest or node level and include your classes at the appropriate level.

If you get your head around the way this works, some of it is very
powerful and elegant.  But whatever the party line, some of it is also
inelegant and hard to work with.  I tend to use node inheritance trees
for defining variables at the appropriate level and class heirarchies to
define function.  Then I include the appropriate high-level classes in
the right nodes.  With care, you can minimise the verbosity in node
definitions but it is still noisier than it should be, because of the
inheritance model.  Look around at the way most people write their
puppet configs and you'll find node definitions littered at the top
level with all the classes a node needs, because it isn't safe to
include them earlier if you're going to want to override values for a
subset of nodes.  This makes node configuration repetitive where it
should be DRY and a potential source of error.  Still, puppet's the best
option around.

-- 
Bruce

The ice-caps are melting, tra-la-la-la.  All the world is drowning,
tra-la-la-la-la.  -- Tiny Tim.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to