[chef] Passing values from resource to resource


Chronological Thread 
  • From: Cary Penniman < >
  • To: " " < >
  • Subject: [chef] Passing values from resource to resource
  • Date: Thu, 13 Dec 2012 16:13:59 -0800

Is there a best practice to pass values from generated in one resource to another?  

My example: 

I have a LWRP that attaches a cloudstack-kvm volume (think EBS volume), but the device name the volume gets attached to cannot be specified in the 'attach' api call, just discovered on the vm after the attach.  What is the best way to pass that device_name value (discovered at converge time) to another resource (e.g. mount or filesystem or lvm)?

The problem:

I assumed setting a node attribute would be the best way, but the attribute value I want is set during the converge phase, and the resource attributes are evaluated at compile time, so that alone doesn't work.  Here is an cookbook snippet that distills my dilemma:

http://pastie.org/5522594

Looking at the pastie snippet, what is the best way to pass the value set in the ruby_block to the log resource in the recipe? 

-Cary P


Archive powered by MHonArc 2.6.16.

§