How do I set the node level attributes in ruby block. I have a use case where I use the attribute across all the resources. I was reading about converge vs compile time, I get it. But I need some suggestions on how to use the lazy evaluation here.
Here is my code, reads a json file and use the value as a node attribute
ruby_block 'package' do
block do
file = open("/tmp/pkg.json")
json = file.read
parsed = JSON.parse(json)
node.override['artifact']['version'] = parsed["artifact"]["version"]
end
only_if { File.exist?("/tmp/pkg.json") }
action :run
end
and recipe follows as
deploy_art = "#{id}-#{node['artifact']['version']}.war". <<--- How do I use lazy eval here?
Tried this, no luck
deploy_art = "#{id}-lazy{ #{node['artifact']['version']}}.war" with lazy eval
I would like to construct deploy_art variable with ruby_block attribute for further logic(s) to work across the recipe. Apparently, I would like to use lazy eval as a clean way.