[chef] postfix wrapper problem


Chronological Thread 
  • From: David Morton < >
  • To:
  • Subject: [chef] postfix wrapper problem
  • Date: Thu, 03 Apr 2014 15:52:10 -0500

The postfix cookbook has all of its examples using roles to set various attributes before running. I've seen a lot of push back on roles, and was trying to make a wrapper cookbook, but there's a gotcha in attribute loading order.

https://wiki.opscode.com/display/chef/Attributes+Cookbook says:

"When Chef loads cookbook attribute files, it does so in alphabetical order for all the cookbooks. If you need to ensure that one attribute file is loaded before another (for example, if your Apache cookbook attributes requires that the Rails cookbook attributes are available first) you can use the include_attribute method"

My wrapper cookbook starts with a "w" so the postfix cookbook comes first. I can't add include_attribute to the postfix cookbook without forking it, and adding include_attribute "postfix" in my own attributes file after I set some defaults, doesn't work, because as I look at the code for include_attribute, it explicitly ignores files it has already loaded.


The problem is, the postfix attribute file does some conditional loading:

if node['postfix']['main']['smtp_sasl_auth_enable'] == 'yes'
default['postfix']['sasl_password_file'] = "#{node['postfix']['conf_dir']}/sasl_passwd"
default['postfix']['main']['smtp_sasl_password_maps'] = "hash:#{node['postfix']['sasl_password_file']}"
  default['postfix']['main']['smtp_sasl_security_options'] = 'noanonymous'
  default['postfix']['sasl']['smtp_sasl_user_name'] = ''
  default['postfix']['sasl']['smtp_sasl_passwd'] = ''
  default['postfix']['main']['relayhost'] = ''
end


If I don't have that node attribute set first, those extra attributes don't get set, and the postfix::sasl_auth file breaks because of nil values. (as a side note, I think if you include postfix::sasl_auth without setting 'smtp_sasl_auth_enable', you are going to hit those same nil errors... maybe this is a bug in the postfix cookbook?)

Nothing I can do in a cookbook or recipe can fix that because the attributes from the postfix cookbook have already been loaded and cannot be reloaded.

so... help? where can I set node['postfix']['main']['smtp_sasl_auth_enable'] before the postfix attribute file is loaded?

workaround: I guess I set all those attributes in my own attributes file?

--
David Morton





Archive powered by MHonArc 2.6.16.

§