LWRP to extends another cookbook LWRP

Hi,

I just want to define a new LWRP to define some different defaults for
attributes of another LWRP.

Googling I’ve found this: http://stackoverflow.com/a/20732016/547195

And I’ve tried with: https://gist.github.com/gionn/6497eefdf9121c832b0e

But I am getting a recipe compile error:

Chef::Exceptions::InvalidResourceSpecification
You must specify resource_name'! /tmp/gionn_chef/cookbooks/cd-infrastructure/definitions/my_docker_container.rb:4:ininitialize’

Any suggestions?

Thanks!


Giovanni Toraldo
http://gionn.net

On May 14, 2015, at 2:42 PM, Giovanni Toraldo me@gionn.net wrote:

Hi,

I just want to define a new LWRP to define some different defaults for
attributes of another LWRP.

Googling I've found this: How to extend a lightweight provider in Chef - Stack Overflow

And I've tried with: https://gist.github.com/gionn/6497eefdf9121c832b0e

But I am getting a recipe compile error:

Chef::Exceptions::InvalidResourceSpecification
You must specify resource_name'! /tmp/gionn_chef/cookbooks/cd-infrastructure/definitions/my_docker_container.rb:4:in initialize'

Any suggestions?

This is not possible with LWRPs for reasons that are both complicated and very boring. Short version? You need to copy-pasta at least some of the upstream LWRP and build a wrapper around it instead of subclassing.

--Noah

On Thu, May 14, 2015 at 10:50 PM, Noah Kantrowitz noah@coderanger.net wrote:

This is not possible with LWRPs for reasons that are both complicated and very boring. Short version? You need to copy-pasta at least some of the upstream LWRP and build a wrapper around it instead of subclassing.

UGH.

An alternative could be to send a PR to the upstream cookbook with a
bunch of new node attributes defined to be used as default values for
the LWRP attributes?

Other suggestions?

--
Giovanni Toraldo

for temporary workaround, you can write a helper method that takes a lwrp
name, and returns the lwrp objects (resource and provider) and you use that
to decorate/compose your new lwrp. in short use LWRPBase.from_file in your
library and pass it the file path (available from run context).
let us know if you need some code samples,
cheers
ranjib

On Thu, May 14, 2015 at 2:06 PM, Giovanni Toraldo me@gionn.net wrote:

On Thu, May 14, 2015 at 10:50 PM, Noah Kantrowitz noah@coderanger.net
wrote:

This is not possible with LWRPs for reasons that are both complicated
and very boring. Short version? You need to copy-pasta at least some of the
upstream LWRP and build a wrapper around it instead of subclassing.

UGH.

An alternative could be to send a PR to the upstream cookbook with a
bunch of new node attributes defined to be used as default values for
the LWRP attributes?

Other suggestions?

--
Giovanni Toraldo
http://gionn.net