Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe Compile Error in /tmp/chef/cookbooks/postfix/recipes/sasl_auth.rb #76

Closed
CloCkWeRX opened this issue Jul 10, 2014 · 7 comments
Closed

Comments

@CloCkWeRX
Copy link

By default, the recipe doesn't work unless you override attributes to enable smtp_sasl_auth_enable => 'yes'

Recipe Compile Error in /tmp/chef/cookbooks/postfix/recipes/sasl_auth.rb
================================================================================


ArgumentError
-------------
You must supply a name when declaring a template resource


Cookbook Trace:
---------------
  /tmp/chef/cookbooks/postfix/recipes/sasl_auth.rb:51:in `from_file'


Relevant File Content:
----------------------
/tmp/chef/cookbooks/postfix/recipes/sasl_auth.rb:

 44:  
 45:  execute 'postmap-sasl_passwd' do
 46:    command "postmap #{node['postfix']['sasl_password_file']}"
 47:    environment 'PATH' => "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
 48:    action :nothing
 49:  end
 50:  
 51>> template node['postfix']['sasl_password_file'] do
 52:    source 'sasl_passwd.erb'
 53:    owner 'root'
 54:    group 'root'
 55:    mode 0400
 56:    notifies :run, 'execute[postmap-sasl_passwd]', :immediately
 57:    notifies :restart, 'service[postfix]'
 58:    variables(settings: node['postfix']['sasl'])
 59:  end
 60:  

This is likely due to the conditional configuration of sasl_password_file

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
@svanharmelen
Copy link
Contributor

That more of less makes sense if you ask me. As smtp_sasl_auth_enable also needs to end up with yes in your main.cf. And for that to happen you indeed need to set/override it to yes

@CloCkWeRX
Copy link
Author

Let me put it another way, if you don't explicitly set smtp_sasl_auth_enable or set it to 'no'; what is the expected behaviour? Right now; the behaviour is You must supply a name when declaring a template resource and the recipe fails to cook.

@svanharmelen
Copy link
Contributor

Well... Personally I don't see why you would want to include the sasl_auth recipe in a nodes runlist, while not having configured the accompanying attributes accordingly.

Of course there could (and maybe should) be a check/guard around the recipe that checks if you are trying to configure your postfix to use sasl auth (e.g. you have smtp_sasl_auth_enable=yes in your main.cf by setting the attribute accordingly), and if not will skip the defined resources.

But still it wouldn't make much sense to call the sasl_auth recipe if you don't enable sasl auth for postfix in your main.cf... Then why run the recipe in the first place?

Or am I totally missing something here? Not a postfix guru, so maybe you know something I don't?

@billmoritz
Copy link

The following code in a wrapper cookbook will cause this error:

node.set['postfix']['main']['smtp_sasl_auth_enable'] = "yes"
include_recipe "postfix"

@chrissnell
Copy link

This bit me, too. The only way I could get it to compile is to set the node.postfix.sasl_password_file attribute in my wrapper cookbook:

default['postfix']['sasl_password_file'] = "#{node['postfix']['conf_dir']}/sasl_passwd"

This cookbook used to work in my old hosted chef repo. Not sure what's going on now.

@chasebolt
Copy link
Contributor

ive done several testing and this issue looks to be resolved by commit 489bfaa, @CloCkWeRX please close this.

@tas50 tas50 closed this as completed Dec 27, 2016
@tas50
Copy link
Contributor

tas50 commented Dec 27, 2016

Closing this out since @chasebolt reports it has been fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants