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

sasl passwd problems with 5.3.0 #148

Open
fletchowns opened this issue Jun 16, 2018 · 7 comments
Open

sasl passwd problems with 5.3.0 #148

fletchowns opened this issue Jun 16, 2018 · 7 comments

Comments

@fletchowns
Copy link

Cookbook version

5.3.0

Chef-client version

12.20.3

Platform Details

Red Hat Enterprise Linux Server release 7.5 (Maipo) on AWS

Scenario:

smtp relay host via SES with sasl uesrname & password

Steps to Reproduce:

I had been using this for awhile in my attributes:

default["postfix"]["main"]["relayhost"] = "email-smtp.us-east-1.amazonaws.com:587"
default["postfix"]["main"]["smtp_sasl_auth_enable"] = "yes"
default["postfix"]["main"]["smtpd_use_tls"] = "no"
default["postfix"]["sasl"]["smtp_sasl_user_name"] = "<snip>"
default["postfix"]["sasl"]["smtp_sasl_passwd"] = "<snip>"

Expected Result:

Previously, this seemed to result in:

default["postfix"]["main"]["relayhost"] = "email-smtp.us-east-1.amazonaws.com:587"
default["postfix"]["main"]["smtp_sasl_auth_enable"] = "yes"
default["postfix"]["main"]["smtpd_use_tls"] = "no"
default["postfix"]["sasl"]["smtp_sasl_user_name"] = "<snip>"
default["postfix"]["sasl"]["smtp_sasl_passwd"] = "<snip>"


$ cat /etc/postfix/sasl_passwd
# Auto-generated by Chef.
# Local modifications will be overwritten.
#
email-smtp.us-east-1.amazonaws.com:587 <snip>:<snip>

Actual Result:

Now with 5.3.0 I ended up with:

$ cat /etc/postfix/sasl_passwd
# Auto-generated by Chef.
# Local modifications will be overwritten.

smtp_sasl_passwd :
smtp_sasl_user_name :

I was able to resolve it by changing the attributes:

default["postfix"]["sasl"] = {
	"email-smtp.us-east-1.amazonaws.com:587" => {
		"username" => "<snip>",
		"password" => "<snip>"
	}
}

It seems like it was a breaking change with a minor version bump though

@koertkuipers
Copy link

we ran into same issue. it broke our deployment.
note that the way @fletchowns resolved it works for us too but it still leaves funny looking empty' values in the file like this:

email-smtp.us-east-1.amazonaws.com:587 <snip>:<snip>
smtp_sasl_passwd :
smtp_sasl_user_name :

@wk8
Copy link

wk8 commented Feb 2, 2019

+1 . This should be caught by unit tests :)

@voroniys
Copy link
Contributor

voroniys commented Mar 12, 2019

I was about to post this issue, but found it is already posted.
The issue is deeper - the recipe code changed, corresponded attributes - does not.
To match what I see in ERB file the lines:

  node.default_unless['postfix']['sasl']['smtp_sasl_user_name'] = ''
  node.default_unless['postfix']['sasl']['smtp_sasl_passwd']    = ''

in /var/chef/cache/cookbooks/postfix/recipes/_attributes.rb file has to be replaced with:

node.default_unless['postfix']['sasl'] = {}

This will eliminate the lines:

smtp_sasl_passwd :
smtp_sasl_user_name :

The actual configuration, as @fletchowns indicated should be:

default["postfix"]["sasl"] = {
	"email-smtp.us-east-1.amazonaws.com:587" => {
		"username" => "<snip>",
		"password" => "<snip>"
	}
}

This needs to be updated in documentation as well.

@scalp42
Copy link

scalp42 commented May 18, 2019

Instead of node['postfix']['sasl'] attributes, simply move them to your namespace say my-cookbook:

default['my-cookbook']['sasl']['[smtp.sendgrid.net]:587'] = {
  'username' => 'SendGridUsername',
  'password' => 'SendGridPassword',
}

Then anywhere in your wrapper cookbook, edit the template resource:

edit_resource!(:template, node['postfix']['sasl_password_file']) do
  variables(settings: node['my-cookbook']['sasl'])
end

You'll end up with the right file:

root@default-ubuntu-1804:/etc/postfix# cat /etc/postfix/sasl_passwd
# Auto-generated by Chef.
# Local modifications will be overwritten.

[smtp.sendgrid.net]:587 SendGridUsername:SendGridPassword

Hopefully it helps! 👨‍🍳

@github-actions
Copy link

github-actions bot commented Oct 9, 2020

Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.

@github-actions github-actions bot added the Stale This is marked as stale and will be closed shortly label Oct 9, 2020
@scalp42
Copy link

scalp42 commented Oct 9, 2020

it's still an issue 😅

@github-actions github-actions bot removed the Stale This is marked as stale and will be closed shortly label Oct 10, 2020
@newfylox
Copy link

newfylox commented Nov 9, 2021

@scalp42 Indeed it's still an issue. Following @voroniys solution feels wrong because we have to edit _attributes.rb file.
Any updates on this?

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