On Oct 16, 2014, at 10:49 AM, Justin Dossey < "> > wrote:
> 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'] })
Use this:
resources(file: '/tmp/foo.txt').owner(Chef::DelayedEvaluator.new { node['foo']['user'] })
#lazy is just a helper method for that, but only available in the resource class scope.
--Noah
Archive powered by MHonArc 2.6.16.