Skip to content

Instantly share code, notes, and snippets.

@BenLiyanage
Last active May 15, 2017 19:39
Show Gist options
  • Save BenLiyanage/2e3eb30ca872b4554d2e49bcf9d104a0 to your computer and use it in GitHub Desktop.
Save BenLiyanage/2e3eb30ca872b4554d2e49bcf9d104a0 to your computer and use it in GitHub Desktop.
Recipe Demonstrating how chef's two pass model, and lazy evaluation interacts
node.set[:lazy] = false
log 'compile evaluation' do
message node[:lazy].to_s
end
# false
log 'execute evaluation' do
message lazy { node[:lazy].to_s }
end
# true
ruby_block 'set lazy during execute' do
block do
node.set[:lazy] = true
end
end
log 'after ruby block not lazy' do
message node[:lazy].to_s
end
# false
log 'lazy' do
message lazy { node[:lazy].to_s }
end
# true
node.set[:lazy] = true
log ' after compile not lazy' do
message node[:lazy].to_s
end
# true
log 'lazy' do
message lazy { node[:lazy].to_s }
end
# true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment