[chef] Re: LWRP inside LWRP Execution Question


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: LWRP inside LWRP Execution Question
  • Date: Mon, 18 Nov 2013 13:33:45 -0800

Title: LWRP inside LWRP Execution Question

On Monday, November 18, 2013 at 12:22 PM, Wes Parish wrote:

Hi Chef experts!

Quick question on LWRP execution.  I am trying to create an LWRP that will allow me to execute ruby code as a user other than root (for example: To install an RPM as myself while running Chef as root).

Currently, my LWRP forks a process, changes the runtime user / group and executes eval() on the command string passed in.  This seems to work perfectly for any native Chef resource, however, it does not execute LWRPs.  It looks like it loads up the resource for the LWRP and is almost like chef-client passes over the resource as if the idempotence check thinks the resource is already converged.

On a side note, it would be a great feature addition if the ruby_block resource in Chef took a "user" attribute to execute a ruby block as a different user.

Any help would be greatly appreciated!

Thanks,
Wes


This happens because of how LWRPs were originally implemented — they would add any native chef resources you use inside an `action` block to the primary resource collection after themselves. This was done so that resources inside the LWRP could notify resources outside of the LWRP. After a lot of real world experience, this doesn’t seem to be the best design, so you can opt in to a different “inline_resources” mode in Chef 11, which will run LWRPs as a nested chef run.

There’s a little more explanation of the inline resources stuff in the docs: http://docs.opscode.com/lwrp_custom_provider.html

HTH,

-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§