- From: Justin Dossey <
>
- To:
- Subject: [chef] Wrapper cookbooks, templates, lazy
- Date: Thu, 16 Oct 2014 10:49:02 -0700
I ran into an interesting one today.
If you're wrapping a (community) cookbook and your wrapper needs lazy {} to move evaluation of something to the execute phase, the #resources method doesn't work.
Example
Cookbook foo, recipes/default.rb
file '/tmp/foo.txt' do
owner node['foo']['user']
end
Cookbook bar, recipes/default.rb
include_recipe 'foo::default'
user 'new_user'
node.override['foo']['user'] = 'new_user'
# this doesn't work:
resources(file: '/tmp/foo.txt').owner( lazy { node['foo']['user'] })
# you have to do this:
file '/tmp/foo.txt' do
owner lazy { node['foo']['user'] }
end
Ideally, I'd be able to do something like this:
resources(file: '/tmp/foo.txt').lazy(:owner)
--
Justin Dossey
Practice Owner
New Context Services, Inc
- [chef] Wrapper cookbooks, templates, lazy, Justin Dossey, 10/16/2014
Archive powered by MHonArc 2.6.16.