[chef] Re: Re: RE: Re: RE: Re: Re: Conditional execution for custom resources


Chronological Thread 
  • From: Jay Feldblum < >
  • To:
  • Subject: [chef] Re: Re: RE: Re: RE: Re: Re: Conditional execution for custom resources
  • Date: Tue, 19 Mar 2013 15:05:30 -0400

Daniel,

Lightweight resources & providers take two files which must be kept in sync. (You could do it in one file in a library, but then you lose the DSL. The fact that it's easy is not in dispute. The point is that it's unnecessary.) The interface and the implementation are forcibly separated, regardless of whether you actually need that separation.

The inline-resources feature is certainly helpful in this context. But that introduces another problem: notifications. Recipe-level resources can't notify inline-resources declared in a provider action. Sometimes what one needs is for the recipe to notify a resource declared from within a macro (or subscribe to one).

When something requires the convenience of grouping but does not require the wall of abstraction, then resources & providers do too much.

Cheers,
Jay

On Tue, Mar 19, 2013 at 2:41 PM, Daniel DeLeo < " target="_blank"> > wrote:

On Tuesday, March 19, 2013 at 11:29 AM, Adam Jacob wrote:

For the record, I agree with you.

 

Best,

Adam

 

From: " target="_blank"> [ " target="_blank">mailto: ] On Behalf Of Jay Feldblum
Sent: Tuesday, March 19, 2013 11:21 AM
To: " target="_blank">
Subject: [chef] Re: RE: Re: Re: Conditional execution for custom resources

 

Definitions are perfectly fine as macros - functions which, when called, declare resources and add them to the resources-collection. So describe them as macros, not as resources, in the docs. That will stop most of the confusion.

Definitions are useful for when you simply need a lightweight grouping of two or more resource declarations, macro-like, where custom resources & providers (including LWRPs) are too heavyweight.

 

Using custom providers like glorified definitions is poor form. If you have a provider which simply declares some sub-resources, why is that a provider? That should be a definition (macro) instead.

 

Cheers,

Jay

Are they really better for that use case though? The amount of boilerplate is about the same, and the use cases are the same, no?

Can you elaborate on what you mean by LWRPs being too heavyweight? Is it just a matter of having two files? Is it the conceptual overhead of thinking in terms of resources and providers?

IMO, making a group of resources a LWRP makes sense as a conceptual grouping. With the `use_inline_resources` feature in Chef 11, notifications and the like should just work the way a user would expect.


-- 
Daniel DeLeo





Archive powered by MHonArc 2.6.16.

§