[chef] Re: New Custom Resources


Chronological Thread 
  • From: Lamont Granquist < >
  • To:
  • Cc: Cassiano Leal < >
  • Subject: [chef] Re: New Custom Resources
  • Date: Fri, 09 Oct 2015 09:24:54 -0700


yeah, you want 1:1 mapping of resources and providers, and then wire them up with provides. look at how the package resources use yum_package resource+provider, apt_package resource+provider and then wire themselves up to package on the DSL. the Chef::Resource::Package resource is now an abstract base class that isn't wired up to 'package' any more (its just used for code sharing). the objects that you can really make are Chef::Resource::YumPackage and Chef::Resource::AptPackage, and those always wrap Chef::Provider::Package::Yum and Chef::Provider::Package::Apt.

the multiple-provider abstraction is really kind of deprecated (but not really) because its a leaky abstraction. once you wind up sprouting different validations that you want to do on the two different providers, then you want to wrap them with 1:1 specific resources that do the validation for the specific provider. the way that Chef 11 worked where you could get a vanilla Chef::Resource::Package that wraps a Chef::Provider::Package::Yum but you couldn't pass any of the yum-specific options through that was mostly confusing -- there's possibly a bit of utility there in being able to validate that the package options you were using were valid across all platforms, but i don't think anyone used it that way, and only the people who really deeply thought about the classes you were instantiating.

and if you look at the service resources with the multiple providers behind it, it is just a disaster. don't ever go down the road of replicating those patterns. that source code should come with a big warning that its an example of a chef antipattern.

On 10/09/2015 07:42 AM, Cassiano Leal wrote:
Hi list,

I’m having a look into the newly released Chef Client 12.5 and I really like 
the new streamlined custom resources.

I couldn’t find information on how to deal with multiple providers in this 
new model though. What’s the thought around that? Create different custom 
resources for what used to be different providers?

Cheers!
Cassiano Leal




Archive powered by MHonArc 2.6.16.

§