Valter Silva
Valter Silva

Reputation: 16656

Why Chef do not find my files?

I'm developing a Ganglia recipe in Chef. Is very simple, I build four different configurations files, I already tried to use as template, but to keep it simple, I build these configuration files.

This is my recipe:

return if tagged?('norun::ganglia')

case node[:platform]
  when "ubuntu", "debian"
    pkg = "ganglia-monitor"
  when "redhat", "centos", "fedora"
    pkg = "ganglia-gmond"
end

package "#{pkg}" do
    action :install
end

cookbook_file "/etc/ganglia/gmond.conf" do
    owner "root"
    group "root"
    mode "0644"
    source "gmond/" + node['base']['dc'] + "/node/gmond.conf" 
end

# Adding ganglia-gmond as service
service "gmond" do
  supports :status => true,
           :restart => true
  action [ :enable, :start ]
end

And this is how my recipe is structured:

cookbooks/ganglia/
cookbooks/ganglia/files/default/gmond/* // I have others sub-folders here too
cookbooks/ganglia/files/default/gmond/diveo/node/gmond.conf
cookbooks/ganglia/recipes/default.rb

But when I tried to run my recipe, it gives the follow error:

[2013-05-14T14:23:38+00:00] FATAL: Chef::Exceptions::FileNotFound: cookbook_file[/etc/ganglia/gmond.conf] (ganglia::default line 25) had an error: Chef::Exceptions::FileNotFound: Cookbook 'ganglia' (0.1.0) does not contain a file at any of these locations:
  files/centos-5.7/gmond/diveo/node/gmond.conf
  files/centos/gmond/diveo/node/gmond.conf
  files/default/gmond/diveo/node/gmond.conf

This cookbook _does_ contain: ['diveo/monitor/gmond.conf','diveo/node/gmond.conf','awsvir/monitor/gmond.conf','awsvir/node/gmond.conf','awssp/monitor/gmond.conf','awssp/node/gmond.conf','alog/monitor/gmond.conf','alog/node/gmond.conf']

Basically it says that I not have the file, but I do, in the right path, right ?

Upvotes: 0

Views: 3415

Answers (1)

If node['base']['dc'] is a platform name, then cookbook_file statement should look like

cookbook_file "/etc/ganglia/gmond.conf" do
    owner "root"
    group "root"
    mode "0644"
    source "gmond.conf"
end

and structure of your conf files should be like that

cookbooks/ganglia/
cookbooks/ganglia/files/default/gmond.conf
cookbooks/ganglia/files/centos-5.7/gmond.conf
...

And a little advice - use template instead of cookbook_file. One day you'll want to add some parameters to your gmane.conf anyway.

Also, here is a cookbook_file doc page from opscode.com -

Upvotes: 3

Related Questions