[chef] Re: Passing values from resource to resource


Chronological Thread 
  • From: Peter Norton < >
  • To:
  • Subject: [chef] Re: Passing values from resource to resource
  • Date: Thu, 13 Dec 2012 19:38:03 -0500

I asked a somewhat related question in IRC yesterday, so I'll take a stab at answering you here.

You can delay the evaluation of the value by enclosing the node in quotes:

log "#{node["network_storage"]["attached_devices"]}"

This way instead of being dereferenced during the compile phase (what's happening now), it'll be evaluated during convergence.

See http://pastie.org/5522742 for a test of this.

-Peter




On Thu, Dec 13, 2012 at 7:13 PM, Cary Penniman < " target="_blank"> > wrote:

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.

§