My chef run recently throws this error:
Chef Client failed. 22 resources updated in 90.306407696 seconds
[2014-12-19T19:47:24+00:00] ERROR: cookbook_file[/srv/mycookbook/static/a.png] (mycookbook::_deploy line 82) had an error: Chef::Exceptions::FileNotFound: Cookbook 'mycookbook' (0.4.5) does not contain a file at any of these locations:
files/ubuntu-12.04/static/a.png
files/ubuntu/static/a.png
files/default/static/a.png
This cookbook _does_ contain: ['a.css','b.html','c.html']
That's because the main cookbook mycookbook
(which I don't own) has these lines:
node['myattributes']['theme']['static_files'].each do |file|
cookbook_file node['myattributes']['install_dir'] + "/static/" + file do
source "static/#{file}"
owner node['myattributes']['user']
group node['myattributes']['group']
cookbook node['myattributes']['theme']['source_cookbook']
end
end
but my child or wrapper cookbook which uses mycookbook
has these lines with different attributes and failed:
override['myattributes']['theme']['compile_files'] = ['a.html']
override['myattributes']['theme']['static_files'] = ['a.png']
And I have these files store under my wrapper cookbook files/default/static/
and files/default/etc/
I already know what the problem is. My wrapper cookbook don't have some files expected by mycookbook
, but why would I ? These attributes should be overriden anyway.
My question is there a better way to handle the files checked under files/default
that the recipe definitions are defined in the parent cookbook, and the wrapper cookbook just define different set of attributes with different files?
You need to set node['myattributes']['theme']['source_cookbook']
to `then name of your wrapper cookbook so it looks in the correct cookbook.