Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chef looking in wrong folder for template

Here's my setup

cookbooks /
    supervisord /
        definitions /
            supervisord_group.erb
        templates /
            process_group.conf.erb
    my_app /
        recipes /
            default.rb

In cookbooks/supervisord/definitions/supervisord_group.erb I have this:

define :supervisord_group, :programs => [], :enable => true do
include_recipe "supervisord::install"

if params[:enable]
    template "#{node[:supervisord][:conf_dir]}/#{params[:name]}_group.conf" do
    source "process_group.conf.erb"
            variables({
        :name => params[:name],
        :programs => params[:programs].join(",")
    })
    owner node[:user]
    group node[:group]
        mode 0755
    end
end
end

In cookbooks/my_app/recipes/default.rb I have this:

supervisord_group "myapps" do
    programs ["test1", "test2"]
end

The problem is that when I run it I get an error that it's unable to find the template process_group.erb.conf. Here's the output:

Cookbook 'my_app' (0.0.0) does not contain a file at any of these locations:
templates/ubuntu-10.04/process_group.conf.erb
templates/ubuntu/process_group.conf.erb
templates/default/process_group.conf.erb

If my supervisord_group definition is the one referencing the template why is it expecting the my_app cookbook to have it? Any ideas?

like image 431
Micah Avatar asked Feb 04 '26 09:02

Micah


1 Answers

So it looks like there is a not-so-clearly-documented property of the template provider that allows you to specify the cookbook that the template lives in. You have to add cookbook "supervisord" to the template setup for it to find it properly.

Thanks to this question

like image 162
Micah Avatar answered Feb 07 '26 06:02

Micah