Skip to content

Instantly share code, notes, and snippets.

@justindossey
Created October 16, 2014 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justindossey/7313509e36c1b271ef24 to your computer and use it in GitHub Desktop.
Save justindossey/7313509e36c1b271ef24 to your computer and use it in GitHub Desktop.
Chef recipe showing order of lazy evaluation
node.default.bar.tags = ['tag1-bar']
file "/tmp/bar.txt" do
content lazy { node.bar.tags.join(',') }
end
ruby_block 'update second tag' do
block { node.default.bar.tags << 'tag2-bar' }
only_if { node.default.bar.tags << 'tag3-bar' }
notifies :create, 'file[/tmp/bar.txt]', :delayed
end
r = resources(file: '/tmp/bar.txt')
r.content(Chef::DelayedEvaluator.new {
node.default.bar.tags << 'tag4-bar'
node.bar.tags.join(',')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment