[chef-dev] Re: forcing parameter to resource to be elevated at execute phase


Chronological Thread 
  • From: AJ Christensen < >
  • To: Chao < >
  • Cc: Chef Dev < >
  • Subject: [chef-dev] Re: forcing parameter to resource to be elevated at execute phase
  • Date: Fri, 21 Dec 2012 12:52:42 +1300

We were thinking about hacking this up today, supporting converge-time evaluation of any parameter by wrapping it in a proc or something.. Seems legit.

Thoughts?

AJ


On 21 December 2012 06:40, Chao < " target="_blank"> > wrote:
hi everyone,

i was wondering if variable passed as parameter to resource can be made to be
elevated at execute phase instead of compile phase. I have the following code
example.

ruby_block "Calculate secret" do
  block do
    node.set['secret_message'] = "This is a secret"
  end
end

file "/tmp/test" do
  content "#{node['secret_message']}"
  mode 0644
end

This is a simplified version of the challenge i have, what i want  is for the
file resource to use a variable node['secret_message'] which is computed by the
ruby_block resource. but the end result is the file /tmp/test contains nothing
because #{node['secret_message']} being ruby code is elevated before the
ruby_block resource is run.

Does anyone know a solution?  if there is a blog post somewhere let me know.

Thanks




Archive powered by MHonArc 2.6.16.

§