On Sep 16, 2010, at 4:57 PM, Ian Ward Comfort wrote:

> On 16 Sep 2010, at 1:03 PM, Nigel Kersten wrote:
>> On Thu, Sep 16, 2010 at 12:49 PM, Jeff McCune <[email protected]> wrote:
>>> Also, please keep in mind this entire discussion applies to resource 
>>> defaults as well.  Whatever behavior we implement for variables should also 
>>> be implemented for resource defaults.
>> 
>> So the plan is that the only place you can reliably set global resource 
>> defaults is directly in your site.pp or in an *import* from site.pp ?
> 
> I actually prefer this, as a matter of policy.  Though we don't use any 
> third-party Puppet code here yet, I'm looking forward to a future date when 
> mixing-and-matching Puppet modules from different sources is feasible and 
> efficient.  And in that world, I want more encapsulation in modules, and that 
> really means lexical, not dynamic scoping.  If a module includes classes from 
> another module, I don't want the former to influence resources in the latter 
> unexpectedly, via dynamically-inherited defaults.

Very much so.

>> and thus not inside a class that may include all your other classes? (we 
>> have a module 'base' that does all the logic for which other classes should 
>> be included)
> 
> Some of this, I would imagine, can be done by parameterizing your other 
> classes -- except the resource defaults, of course.  Though for that I guess 
> you could do:
> 
>    class app_x ($default_file_owner) {
>      File { owner => $default_file_owner)
>      ... other content ...
>    }

This is basically the prime thing that's kept me from pulling the trigger on 
switching to a lexical scope, I think - I've implemented it at least once in 
the past.

> We have a different way of handling this here, though.  I have a 'defaults' 
> module with contents like:
> 
>    File { owner => 'root' }
>    Exec { path => '/bin:/usr/bin:/sbin:/usr/sbin' }
>    ... and so on ...
> 
> And virtually all of our other classes inherit the defaults class (or some 
> other class, which is itself a descendant of defaults).  This saves typing, 
> compacts our code a *lot*, and somewhat reduces errors due to forgetfulness.

I think it'd be very interesting to do a survey of how people use resource 
defaults.  I'm especially curious to see how many actually use it in individual 
classes, rather than globally.

-- 
If computers get too powerful, we can organize them into a committee --
that will do them in.    -- Bradley's Bromide
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199




-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" 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-dev?hl=en.

Reply via email to