This is incorrect and is just a side effect of chef-shell being a bit odd. String interpolation is a Ruby feature and will happen at compile time as normal. If you want to delay runtime of something you need to wrap it in a ruby_block or LWRP. You can either use node attars to communicate between resources, or node.run_state which is a hash that is reset for each run.
On Dec 13, 2012, at 4:38 PM, Peter Norton wrote:
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:
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.
On Thu, Dec 13, 2012 at 7:13 PM, Cary Penniman email@example.com wrote:
Is there a best practice to pass values from generated in one resource to another?
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)?
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:
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?