Over on the users list, I have lately been involved in a conversation 
<https://groups.google.com/forum/#!topic/puppet-users/vQRNCDQacOc> about 
evaluation-order issues related to the puppetlabs-apache module, and about 
the semantics of classes declared via ENC both with and without 
parameters.  The Puppet behavior reported by the user seems to be 
reasonable given the manifests, and the manifests seem reasonably well 
designed, yet the result is poor.  This has gotten me doing some 
reverse-engineering, and some thinking about how Puppet could better handle 
ENC-declared classes.

One of the key observations feeding my reverse engineering was that the 
order in which Puppet evaluated the same set of ENC-declared classes 
depended on which of those classes had any parameter values expressed in 
the ENC output.  The ones having ENC-specified parameter values seemed 
always to be evaluated before those that didn't, even though it was the 
same classes declared, in the same document order.  I'm not prepared to 
accept that the order of the entries in the 'classes' hash depends on 
anything but the keys and possibly the order in which they appear in the 
YAML input, so it follows that Puppet is intentionally processing the 
explicit-parameter classes first, and the others second.

Well that makes sense if it reduces the likelihood of a duplicate class 
declaration error, which would be the case if Puppet handles such classes 
in the same manner as resource-like class declarations in the DSL.  That's 
a pretty natural mapping, so I have no trouble believing that it works like 
that.  If that's not the reason then I'm baffled.

(Object here if my chain of inference is wrong.)

Supposing that I have reasoned rightly, I would like to suggest that Puppet 
doesn't need to handle ENC-declared classes like that, and it shouldn't do, 
no matter how natural it may be.  It shouldn't handle any ENC-declared 
class in a manner that has the evaluation-order implications of a 
resource-like class declaration because those are troublesome both in 
theory and in practice.  Processing those classes first reduces the 
likelihood of the associated problems arising, but does not eliminate it.

How then to apply the ENC-specified parameters?  [drum roll...] By 
inserting them into the data-binding framework as the highest-priority data 
source aside from resource-like declarations, and handling all classes 
specified by the ENC as if declared via 'include'.

That would eliminate ENC class handling as a possible source of duplicate 
class declaration errors, and it should generally simplify that process as 
well.  It would not cause any errors that do not or could not arise already.

The only potential compatibility problem I see is that certain combinations 
of ENC output and manifests that now can or do produce catalog building 
errors, might instead proceed without error.  These would be cases where a 
resource-like class declaration appears in DSL for a class that is also 
declared, with parameters, via ENC.  That ought to always cause an error 
with current Puppet (supposing again that I have analyzed it rightly), but 
with the change I propose it might sometimes succeed, with the DSL 
declaration overriding the ENC where they assign values to the same 
parameters.  (That's not a special case, just a natural consequence of the 
approach I'm describing.)


Thoughts?



John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/ae65b1c7-6d6d-4022-9c5b-bb2399445ee4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to