[chef] Re: after_created in LWRPs


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: after_created in LWRPs
  • Date: Sun, 5 May 2013 08:53:44 -0700


On Thursday, May 2, 2013 at 11:28 PM, Peter Donald wrote:

Hi,

In our infrastructure we have had the need for some of our LWRPs to
take some action during the compile phase rather than the converge
phase. Mostly this involves publishing calculated values as attribute
data so a later resource can make use of the attribute data. We have
been doing this by overriding the after_created hook in resources. So
the question is ... is this something anyone else is doing or is it
insanely bad in some way I can't figure out just yet. Thoughts?

i.e. We a LWRP similar to ark that downloads and extracts archives and
optionally publishes the directory to which the archive will be
extracted as attribute data. We then use this attribute data in a
following resource definition. See [1]


--
Cheers,

Peter Donald
I'd advise not to rely on callbacks and side-effects like this. Someone who's not familiar with this is gonna have a bad time trying to figure out where the data comes from.

Why not use another LWRP or resource definition that wraps both?

Alternatively, you can ask your LWRP resource where it thinks the data should go, with something like:

  resources("chef_archive[NAME]").base_directory

HTH,

-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§