[chef] cascade update dependent attributes


Chronological Thread 
  • From: Daneel Yaitskov < >
  • To:
  • Subject: [chef] cascade update dependent attributes
  • Date: Sun, 1 Dec 2013 01:04:59 +0400

Hi,


Is any body faced with such problem?

cookbook1 attributes

default[:a] = 1
default[:b] = "use-#{ node.a }"

cookbook2 attributes

override[:a] = 2


I found that in the cassandra cookbook.
The problem is if I want to change one attribute in the wrapper cookbook I have to change both attributes.
Otherwise error happens because ruby make substitution before cookbook2 is loaded.

Does Chef has any standard method to cope with it?

I see a simple solution:

class DynamicAttribute
  def initialize(&block)
    @block = block
  end
  def to_s
    @block.call
  end
end

Usage:
default[:a] = DynamicAttribute.new do "use-#{ node.a }" end


It's unwieldy a little.
Is any ideas how to humanize it?





--
Daneel S. Yaitskov



Archive powered by MHonArc 2.6.16.

§