On Apr 12, 10:49 am, Patrick <[email protected]> wrote:
> On Apr 12, 2011, at 8:03 AM, jcbollinger wrote:
>
> > 1) parameterized classes can be included only once, unlike
> > unparameterized ones.  This tends to require modules to have an
> > hierarchical structure, which isn't very suitable in many
> > circumstances.  (More on that below.)  It does, however, sort of
> > address
>
> My understanding is that there's no difference between "parameterized classes 
> you can include more than once" and defines.  If you disagree, please 
> enlighten me.

Stand by for enlightenment.

You can include unparameterized classes any number of times, and it
means the same thing whether you include a class once or a hundred
times.  This is one of the fundamental characteristics of Puppet
classes, and a feature that I personally put to good use.  There is no
reason in principle why you should not be able to include
parameterized classes multiple times as well, provided that the
parameters are everywhere the same for a given node.  My expectation
for such a case would be that the effect is the same as including the
class only once, just as for unparameterized classes.

Defines are altogether different: they are resource types written in
Puppet DSL, much more akin to File or User than to any class.  Whereas
it must be an error to include a class two or more times with
inconsistent parameter sets, multiple instantiations of a define
*must* differ, at least in their titles.  Whereas multiple inclusions
of the same parameterized class (with consistent parameters) should
mean the same as a single inclusion of that class, multiple
instantiations of a define model separate resources to manage.

Defines are nevertheless relevant to the discussion, because they can
indeed serve in most of the roles for which parameterized classes are
suggested.  Since parameterized classes can only be included once
anyway, the most significant distinction between a parameterized class
and a define is largely mooted in practice.  This then begs the
question: for what purpose are parameterized classes uniquely useful?
I may be missing something, but the only things I come up with are

1) Run stages.  You cannot assign individual resources to stages, only
classes, and you can only assign classes to stages via the parameter
list syntax.  That's rather arbitrary, though, and I wonder whether
you can get around it by using "before => Stage['foo']" on ordinary
resources instead of "stage => foo" on classes.

2) External node classifiers.  I think providing for ENCs to set class
data is the main reason we now have parameterized classes.  There is
no particular reason, though, why parameterized classes needed to be
provided to give ENCs such a capability.


John

-- 
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.

Reply via email to