[chef] Re: Passing blocks as LWRP attributes


Chronological Thread 
  • From: Jay Feldblum < >
  • To:
  • Subject: [chef] Re: Passing blocks as LWRP attributes
  • Date: Tue, 4 Dec 2012 11:34:50 -0500

Benton,

https://github.com/opscode/chef/blob/10.16.2/chef/lib/chef/resource/deploy.rb#L369-L373

Cheers,
Jay

On Tue, Dec 4, 2012 at 11:26 AM, Benton Roberts < " target="_blank"> > wrote:
Ohai, chefs!

I am trying to write a LWRP that "wraps" the Opscode deploy_revision Provider to add some organization-specific functionality. The LWRP sets some organization-wide defaults, defines some supporting Chef Resources, and then defines the usual Opscode deploy_revision Resource. Many of the attributes for my LWRP simply pass their values through to the deploy_revision Resource, exactly as one would expect:

deploy_revision app_name do
  revision          new_resource.revision
  repository        new_resource.repository
  migration_command new_resource.migration_command
  enable_submodules new_resource.enable_submodules
…[and so on]

This works fine for simple value attributes like those listed above, but does not seem to work for the block attributes: before_migrate, after_symlink, etc. Using the same syntax (a regular "do…end" statement passed as an argument to the LWRP's before_migrate method) just yields a value of nil for "new_resource.before_migrate".

Is there a way to pass blocks to an LWRP, and then pass them onto deploy_revision so that the blocks get invoked in the same context (i.e. "releases_dir")? How would you handle this situation?

Thanks in advance,
- benton
------------
Benton Roberts
">





Archive powered by MHonArc 2.6.16.

§