Lazy evaluation


#1

I have an attribute (node[‘name’]), which value is calculated during execution time (in a ruby_block).
I have another ruby_block which uses the value of the calculated attribute.
I can’t figure out the correct syntax for the second block. I know I need to use the lazy key word.
Here is what I have:

ruby_block “do something” do
block do
require 'mixlib/shellout’
command = "git config xxxx #{node[‘name’]}"
Mixlib::ShellOut.new(command)
curl.run_command
end
end


#2

Sounds strange, your ruby block should get the updated value (running at converge time), wherever you’re updating the value.

However I wonder if node['name'] is not an automatic attribute an protected as it is the name used by chef to sign requests.


#3

Right. I have figured it eventually.