[chef] Re: Re: Defining attributes for cookbook in recipe has different behavior than attributes from roles


Chronological Thread 
  • From: William Jimenez < >
  • To:
  • Cc:
  • Subject: [chef] Re: Re: Defining attributes for cookbook in recipe has different behavior than attributes from roles
  • Date: Thu, 4 Dec 2014 12:04:18 -0800

Thanks Galen, I just tried changing the attributes file to 

force_override['chef-client']['config']['exception_handlers'] = [ 
  {"class" => "MailHandler", "arguments" => [{:template_path => "#{exception_mail_template}"}]
    }]
force_override['chef-client']['load_gems'] = [
  {"chef-handler-mail" => {"require_name" => "chef/handler/mail"}
  }]


No difference. What else could it be?



On Thu, Dec 4, 2014 at 11:54 AM, Galen Emery < " target="_blank"> > wrote:


On Wed, Dec 3, 2014 at 11:37 PM, William Jimenez < " target="_blank"> > wrote:
Hello
  1. I'm using the opscode chef-client cookbook, and I am trying to define attributes for the cookbook from a wrapper recipe, however they don't seem to be honored. When I define them in a role the node is in, it works however (working meaning chef_client operates on the attributes). What is different about the two?

Here is my attributes file: 

exception_mail_template = "/opt/chef/mail_hanlder_template.erb"

default['chef-client']['config']['exception_handlers'] = [ 
  {"class" => "MailHandler", "arguments" => [{:template_path => "#{exception_mail_template}"}]
    }]
default['chef-client']['load_gems'] = [
  {"chef-handler-mail" => {"require_name" => "chef/handler/mail"}
  }]


and portion of my recipe where I call chef_client

# Exception handling for chef client runs
chef_gem "chef-handler-mail" do
   action :install
end

# Install exception handler email template
exception_mail_template = "/opt/chef/mail_hanlder_template.erb"

cookbook_file "#{exception_mail_template}" do 
  source "mail_handler.erb"
end
          
include_recipe "chef-client::config"

Thanks



Attribute Precedence is probably what's screwing you up: http://docs.getchef.com/attributes.html#attribute-precedence

Your default attribute in your attributes file would have the same precedence as the cookbook.  So order wins.  A role will win though.







Archive powered by MHonArc 2.6.16.

§