Similar things are commonly found in chef recipes:
%w{foo bar baz}.each do |x| file "#{x}" do content "whatever" end end
But I want to read the elements that need to be sorted out from a file that is stored in the cookbook, for example:
File.open('files/default/blah.txt').each do |x| file "#{x}" do content "whatever" end end
This works if I give the full path to blah.txt , where the cache client performs caching, but it is not portable. This does not work if I write it, as in the example, βhopingβ that the current directory is the root of the cookbook. Is there a way to get the root directory of a cookbook when compiling recipes?
source share