- From: Benton Roberts <
>
- To:
- Subject: [chef] Passing blocks as LWRP attributes
- Date: Tue, 4 Dec 2012 11:26:42 -0500
- Domainkey-signature: a=rsa-sha1; c=nofws; d=bentonroberts.com; h=from :content-type:content-transfer-encoding:subject:date:message-id :to:mime-version; q=dns; s=bentonroberts.com; b=S7scrgxwIvS6M9xT WKag9uVETRsGSIWo4Tw/RTXO6MnPRAYC9wG3/d96oCEd8SaywccnAH/jf/UJaaaa xwlh3MUX2teZeHqJrVmPIQLbu4VNTvGPOzo66Zz51q/BwxoC8YGP3i4ljnPN2pCr IXLhqmaai42bU+pgrG69ZXoYFRg=
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
- [chef] Passing blocks as LWRP attributes, Benton Roberts, 12/04/2012
Archive powered by MHonArc 2.6.16.