LWRP being defined inside libraries directory?

Is there a new pattern i'm missing?

--
Si necesitas una máquina para hacer algo y no la compras al final te darás
cuenta de que has pagado lo mismo y no tienes la máquina.--Henry Ford

Alberto

On Tue, Nov 4, 2014 at 9:38 AM, aL. ocholetrasaleatorias@gmail.com wrote:

https://github.com/opscode-cookbooks/database/tree/master/libraries

Is there a new pattern i'm missing?

I wouldn't say it's "new"; the code in there dates back to 2011.

But recently, we've done some more work to explore how heavyweight
resources -- that is, those that subclass Chef::Resource and
Chef::Provider directly -- could make for much more reusable
cookbooks. You can see examples of this in the 'httpd' and 'mysql'
cookbooks.

In other words, everything old is new again. [1]

  • Julian

[1] https://www.youtube.com/watch?v=oAjSWZQNXLU

[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

On Tuesday, November 4, 2014 at 6:38 AM, aL. wrote:

https://github.com/opscode-cookbooks/database/tree/master/libraries

Is there a new pattern i'm missing?

These are what people are calling “heavy weight resources and providers” or HWRP. The downside of doing this is that you need to write your code in a more pure ruby way, with less help from the DSL. The benefit is that you fully control the class names (and therefore the names of resources, too). It also means you don’t need as much magic to be able to test your code. If you want to test a LWRP in isolation, you have to know to use this method: https://github.com/opscode/chef/blob/ff9147776117f6a5592449384ab6f6ff6605e9be/lib/chef/provider/lwrp_base.rb#L83 in order to make Chef create the LWRP classes, which is not something most people know to do.

Noah has been working on a sort of middle ground, with his poise stuff, see here: GitHub - poise/poise: A set of libraries for writing reusable Chef cookbooks

--
Si necesitas una máquina para hacer algo y no la compras al final te darás cuenta de que has pagado lo mismo y no tienes la máquina.--Henry Ford

Alberto

--
Daniel DeLeo

Jon Cowie's book Customizing Chef [Book] has a
good chapter on HWRPs.

On Tue, Nov 4, 2014 at 10:48 AM, Daniel DeLeo dan@kallistec.com wrote:

On Tuesday, November 4, 2014 at 6:38 AM, aL. wrote:

https://github.com/opscode-cookbooks/database/tree/master/libraries

Is there a new pattern i'm missing?

These are what people are calling “heavy weight resources and providers”
or HWRP. The downside of doing this is that you need to write your code in
a more pure ruby way, with less help from the DSL. The benefit is that you
fully control the class names (and therefore the names of resources, too).
It also means you don’t need as much magic to be able to test your code. If
you want to test a LWRP in isolation, you have to know to use this method:
https://github.com/opscode/chef/blob/ff9147776117f6a5592449384ab6f6ff6605e9be/lib/chef/provider/lwrp_base.rb#L83
in order to make Chef create the LWRP classes, which is not something most
people know to do.

Noah has been working on a sort of middle ground, with his poise stuff,
see here: GitHub - poise/poise: A set of libraries for writing reusable Chef cookbooks

--
Si necesitas una máquina para hacer algo y no la compras al final te
darás cuenta de que has pagado lo mismo y no tienes la máquina.--Henry Ford

Alberto

--
Daniel DeLeo

We have a page about these on chef-docs as well:

http://docs.getchef.com/lwrp_custom_resource_library.html

Here's the overview page for building custom resources:
http://docs.getchef.com/lwrp_custom.html

As Peter already mentioned, Jon Cowie's book has a terrific chapter on the
HWRP approach.

On Tue, Nov 4, 2014 at 8:15 AM, Peter Burkholder pburkholder@getchef.com
wrote:

Jon Cowie's book Customizing Chef [Book] has a
good chapter on HWRPs.

On Tue, Nov 4, 2014 at 10:48 AM, Daniel DeLeo dan@kallistec.com wrote:

On Tuesday, November 4, 2014 at 6:38 AM, aL. wrote:

https://github.com/opscode-cookbooks/database/tree/master/libraries

Is there a new pattern i'm missing?

These are what people are calling “heavy weight resources and providers”
or HWRP. The downside of doing this is that you need to write your code in
a more pure ruby way, with less help from the DSL. The benefit is that you
fully control the class names (and therefore the names of resources, too).
It also means you don’t need as much magic to be able to test your code. If
you want to test a LWRP in isolation, you have to know to use this method:
https://github.com/opscode/chef/blob/ff9147776117f6a5592449384ab6f6ff6605e9be/lib/chef/provider/lwrp_base.rb#L83
in order to make Chef create the LWRP classes, which is not something most
people know to do.

Noah has been working on a sort of middle ground, with his poise stuff,
see here: GitHub - poise/poise: A set of libraries for writing reusable Chef cookbooks

--
Si necesitas una máquina para hacer algo y no la compras al final te
darás cuenta de que has pagado lo mismo y no tienes la máquina.--Henry Ford

Alberto

--
Daniel DeLeo