[COOK-4619] - no way to unset recipient_delimiter

Signed-off-by: Sean OMeara <someara@opscode.com>
This commit is contained in:
Patrick Moore 2014-05-09 13:51:12 -04:00 committed by Sean OMeara
parent f27480fa4c
commit 0a42b0722b
14 changed files with 78 additions and 68 deletions

View File

@ -15,8 +15,8 @@ platforms:
run_list: run_list:
- recipe[apt] - recipe[apt]
- name: centos-6.4 - name: centos-6.5
- name: centos-5.9 - name: centos-5.10
- name: omnios-r151006c - name: omnios-r151006c
driver: driver:
box: omnios-r151006c box: omnios-r151006c

4
.rubocop.yml Normal file
View File

@ -0,0 +1,4 @@
Encoding:
Enabled: False
LineLength:
Max: 200

View File

@ -43,7 +43,6 @@ This change in namespace to `node['postfix']['main']` should allow for greater f
* `node['postfix']['main']['inet_interfaces']` - set to `loopback-only`, or `all` for server recipe * `node['postfix']['main']['inet_interfaces']` - set to `loopback-only`, or `all` for server recipe
* `node['postfix']['main']['alias_maps']` - set to `hash:/etc/aliases` * `node['postfix']['main']['alias_maps']` - set to `hash:/etc/aliases`
* `node['postfix']['main']['mailbox_size_limit']` - set to `0` (disabled) * `node['postfix']['main']['mailbox_size_limit']` - set to `0` (disabled)
* `node['postfix']['main']['recipient_delimiter']` - set to `+`
* `node['postfix']['main']['mydestination']` - default fqdn, hostname, localhost.localdomain, localhost * `node['postfix']['main']['mydestination']` - default fqdn, hostname, localhost.localdomain, localhost
* `node['postfix']['main']['smtpd_use_tls']` - (yes/no); default yes. See conditional cert/key attributes. * `node['postfix']['main']['smtpd_use_tls']` - (yes/no); default yes. See conditional cert/key attributes.
- `node['postfix']['main']['smtpd_tls_cert_file']` - conditional attribute, set to full path of server's x509 certificate. - `node['postfix']['main']['smtpd_tls_cert_file']` - conditional attribute, set to full path of server's x509 certificate.

View File

@ -49,7 +49,6 @@ default['postfix']['main']['smtpd_use_tls'] = 'yes'
default['postfix']['main']['smtp_use_tls'] = 'yes' default['postfix']['main']['smtp_use_tls'] = 'yes'
default['postfix']['main']['alias_maps'] = ["hash:#{node['postfix']['aliases_db']}"] default['postfix']['main']['alias_maps'] = ["hash:#{node['postfix']['aliases_db']}"]
default['postfix']['main']['mailbox_size_limit'] = 0 default['postfix']['main']['mailbox_size_limit'] = 0
default['postfix']['main']['recipient_delimiter'] = '+'
default['postfix']['main']['smtp_sasl_auth_enable'] = 'no' default['postfix']['main']['smtp_sasl_auth_enable'] = 'no'
default['postfix']['main']['mynetworks'] = '127.0.0.0/8' default['postfix']['main']['mynetworks'] = '127.0.0.0/8'
default['postfix']['main']['inet_interfaces'] = 'loopback-only' default['postfix']['main']['inet_interfaces'] = 'loopback-only'

View File

@ -11,41 +11,41 @@ recipe 'postfix::aliases', 'Manages /etc/aliases'
recipe 'postfix::client', 'Searches for the relayhost based on an attribute' recipe 'postfix::client', 'Searches for the relayhost based on an attribute'
recipe 'postfix::server', 'Sets the mail_type attribute to master' recipe 'postfix::server', 'Sets the mail_type attribute to master'
%w{ubuntu debian redhat centos amazon scientific smartos}.each do |os| %w(ubuntu debian redhat centos amazon scientific smartos).each do |os|
supports os supports os
end end
attribute 'postfix/main', attribute 'postfix/main',
display_name: 'postfix/main', display_name: 'postfix/main',
description: 'Hash of Postfix main.cf attributes', description: 'Hash of Postfix main.cf attributes',
type: 'hash' type: 'hash'
attribute 'postfix/aliases', attribute 'postfix/aliases',
display_name: 'Postfix Aliases', display_name: 'Postfix Aliases',
description: "Hash of Postfix aliases mapping a name to a value. Example 'root' => 'operator@example.com'. See aliases man page for details.", description: "Hash of Postfix aliases mapping a name to a value. Example 'root' => 'operator@example.com'. See aliases man page for details.",
type: 'hash' type: 'hash'
attribute 'postfix/mail_type', attribute 'postfix/mail_type',
display_name: 'Postfix Mail Type', display_name: 'Postfix Mail Type',
description: 'Is this node a client or server?', description: 'Is this node a client or server?',
default: 'client' default: 'client'
attribute 'postfix/smtp_sasl_user_name', attribute 'postfix/smtp_sasl_user_name',
display_name: 'Postfix SMTP SASL Username', display_name: 'Postfix SMTP SASL Username',
description: 'User to auth SMTP via SASL', description: 'User to auth SMTP via SASL',
default: '' default: ''
attribute 'postfix/smtp_sasl_passwd', attribute 'postfix/smtp_sasl_passwd',
display_name: 'Postfix SMTP SASL Password', display_name: 'Postfix SMTP SASL Password',
description: 'Password for smtp_sasl_user_name', description: 'Password for smtp_sasl_user_name',
default: '' default: ''
attribute 'postfix/relayhost_role', attribute 'postfix/relayhost_role',
display_name: "Postfix Relayhost's role", display_name: "Postfix Relayhost's role",
description: 'String containing the role name', description: 'String containing the role name',
default: 'relayhost' default: 'relayhost'
attribute 'postfix/use_procmail', attribute 'postfix/use_procmail',
display_name: 'Postfix Use procmail?', display_name: 'Postfix Use procmail?',
description: 'Whether procmail should be used as the local delivery agent for a server', description: 'Whether procmail should be used as the local delivery agent for a server',
default: 'no' default: 'no'

View File

@ -18,7 +18,7 @@ include_recipe 'postfix'
execute 'update-postfix-aliases' do execute 'update-postfix-aliases' do
command 'newaliases' command 'newaliases'
environment :PATH => "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios') environment PATH: "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
action :nothing action :nothing
end end

View File

@ -25,7 +25,7 @@ end
query = "role:#{node['postfix']['relayhost_role']}" query = "role:#{node['postfix']['relayhost_role']}"
relayhost = '' relayhost = ''
results = [] # results = []
if node.run_list.roles.include?(node['postfix']['relayhost_role']) if node.run_list.roles.include?(node['postfix']['relayhost_role'])
relayhost << node['ipaddress'] relayhost << node['ipaddress']

View File

@ -20,9 +20,7 @@
package 'postfix' package 'postfix'
if node['postfix']['use_procmail'] package 'procmail' if node['postfix']['use_procmail']
package 'procmail'
end
case node['platform_family'] case node['platform_family']
when 'rhel', 'fedora' when 'rhel', 'fedora'
@ -37,7 +35,7 @@ when 'rhel', 'fedora'
not_if '/usr/bin/test /etc/alternatives/mta -ef /usr/sbin/sendmail.postfix' not_if '/usr/bin/test /etc/alternatives/mta -ef /usr/sbin/sendmail.postfix'
end end
when 'omnios' when 'omnios'
manifest_path = ::File.join(Chef::Config[:file_cache_path], "manifest-postfix.xml") manifest_path = ::File.join(Chef::Config[:file_cache_path], 'manifest-postfix.xml')
# we need to manage the postfix group and user # we need to manage the postfix group and user
# and then subscribe to the package install because it creates a # and then subscribe to the package install because it creates a
@ -62,13 +60,13 @@ when 'omnios'
owner 'root' owner 'root'
group 'root' group 'root'
mode 00644 mode 00644
notifies :run, "execute[load postfix manifest]", :immediately notifies :run, 'execute[load postfix manifest]', :immediately
end end
execute "load postfix manifest" do execute 'load postfix manifest' do
action :nothing action :nothing
command "svccfg import #{manifest_path}" command "svccfg import #{manifest_path}"
notifies :restart, "service[postfix]" notifies :restart, 'service[postfix]'
end end
end end
@ -77,7 +75,7 @@ execute 'update-postfix-sender_canonical' do
action :nothing action :nothing
end end
if !node['postfix']['sender_canonical_map_entries'].empty? unless node['postfix']['sender_canonical_map_entries'].empty?
template "#{node['postfix']['conf_dir']}/sender_canonical" do template "#{node['postfix']['conf_dir']}/sender_canonical" do
owner 'root' owner 'root'
group 0 group 0
@ -86,12 +84,12 @@ if !node['postfix']['sender_canonical_map_entries'].empty?
notifies :reload, 'service[postfix]' notifies :reload, 'service[postfix]'
end end
if !node['postfix']['main'].key?('sender_canonical_maps') unless node['postfix']['main'].key?('sender_canonical_maps')
node.set['postfix']['main']['sender_canonical_maps'] = "hash:#{node['postfix']['conf_dir']}/sender_canonical" node.set['postfix']['main']['sender_canonical_maps'] = "hash:#{node['postfix']['conf_dir']}/sender_canonical"
end end
end end
%w{main master}.each do |cfg| %w(main master).each do |cfg|
template "#{node['postfix']['conf_dir']}/#{cfg}.cf" do template "#{node['postfix']['conf_dir']}/#{cfg}.cf" do
source "#{cfg}.cf.erb" source "#{cfg}.cf.erb"
owner 'root' owner 'root'

View File

@ -27,15 +27,15 @@ sasl_pkgs = []
# version specifics for RHEL. # version specifics for RHEL.
case node['platform_family'] case node['platform_family']
when 'debian' when 'debian'
sasl_pkgs = %w{libsasl2-2 libsasl2-modules ca-certificates} sasl_pkgs = %w(libsasl2-2 libsasl2-modules ca-certificates)
when 'rhel' when 'rhel'
if node['platform_version'].to_i < 6 if node['platform_version'].to_i < 6
sasl_pkgs = %w{cyrus-sasl cyrus-sasl-plain openssl} sasl_pkgs = %w(cyrus-sasl cyrus-sasl-plain openssl)
else else
sasl_pkgs = %w{cyrus-sasl cyrus-sasl-plain ca-certificates} sasl_pkgs = %w(cyrus-sasl cyrus-sasl-plain ca-certificates)
end end
when 'fedora' when 'fedora'
sasl_pkgs = %w{cyrus-sasl cyrus-sasl-plain ca-certificates} sasl_pkgs = %w(cyrus-sasl cyrus-sasl-plain ca-certificates)
end end
sasl_pkgs.each do |pkg| sasl_pkgs.each do |pkg|
@ -55,5 +55,5 @@ template node['postfix']['sasl_password_file'] do
mode 0400 mode 0400
notifies :run, 'execute[postmap-sasl_passwd]', :immediately notifies :run, 'execute[postmap-sasl_passwd]', :immediately
notifies :restart, 'service[postfix]' notifies :restart, 'service[postfix]'
variables(:settings => node['postfix']['sasl']) variables(settings: node['postfix']['sasl'])
end end

View File

@ -13,6 +13,10 @@ describe 'postfix::default' do
it '[COOK-4423] renders file main.cf with /etc/pki/tls/cert.pem' do it '[COOK-4423] renders file main.cf with /etc/pki/tls/cert.pem' do
expect(chef_run).to render_file('/etc/postfix/main.cf').with_content(%r{smtp_tls_CAfile += +/etc/pki/tls/cert.pem}) expect(chef_run).to render_file('/etc/postfix/main.cf').with_content(%r{smtp_tls_CAfile += +/etc/pki/tls/cert.pem})
end end
it '[COOK-4619] does not set recipient_delimiter' do
expect(chef_run).to_not render_file('/etc/postfix/main.cf').with_content('recipient_delimiter')
end
end end
context 'on SmartOS' do context 'on SmartOS' do
@ -21,7 +25,11 @@ describe 'postfix::default' do
end end
it '[COOK-4423] renders file main.cf without smtp_use_tls' do it '[COOK-4423] renders file main.cf without smtp_use_tls' do
expect(chef_run).to render_file('/opt/local/etc/postfix/main.cf').with_content(%r{smtp_use_tls += +no}) expect(chef_run).to render_file('/opt/local/etc/postfix/main.cf').with_content(/smtp_use_tls += +no/)
end
it '[COOK-4619] does not set recipient_delimiter' do
expect(chef_run).to_not render_file('/etc/postfix/main.cf').with_content('recipient_delimiter')
end end
end end
@ -33,5 +41,9 @@ describe 'postfix::default' do
it '[COOK-4423] renders file main.cf with /etc/postfix/cacert.pem' do it '[COOK-4423] renders file main.cf with /etc/postfix/cacert.pem' do
expect(chef_run).to render_file('/etc/postfix/main.cf').with_content(%r{smtp_tls_CAfile += +/etc/postfix/cacert.pem}) expect(chef_run).to render_file('/etc/postfix/main.cf').with_content(%r{smtp_tls_CAfile += +/etc/postfix/cacert.pem})
end end
it '[COOK-4619] does not set recipient_delimiter' do
expect(chef_run).to_not render_file('/etc/postfix/main.cf').with_content('recipient_delimiter')
end
end end
end end

View File

@ -1,3 +1,3 @@
name "fake" name 'fake'
version "0.0.1" version '0.0.1'
description "Not a real cookbook, used for testing only." description 'Not a real cookbook, used for testing only.'

View File

@ -1,5 +1,5 @@
execute "pkg set-publisher -g http://pkg.omniti.com/omniti-ms/ ms.omniti.com" do execute 'pkg set-publisher -g http://pkg.omniti.com/omniti-ms/ ms.omniti.com' do
not_if "pkg publisher ms.omniti.com" not_if 'pkg publisher ms.omniti.com'
end end
execute "pkg refresh --full" execute 'pkg refresh --full'

View File

@ -28,7 +28,7 @@ describe 'postfix::default' do
context 'configures' do context 'configures' do
describe file('/etc/postfix/main.cf') do describe file('/etc/postfix/main.cf') do
its(:content) { should match /^# Generated by Chef for / } its(:content) { should match(/^# Generated by Chef for /) }
end end
end end
end end

View File

@ -19,12 +19,10 @@ describe 'postfix::sasl_auth' do
let(:sasl_passwd_file) { '/etc/postfix/sasl_passwd' } let(:sasl_passwd_file) { '/etc/postfix/sasl_passwd' }
it 'manages postfix sasl_passwd' do it 'manages postfix sasl_passwd' do
expect(file(sasl_passwd_file).content). expect(file(sasl_passwd_file).content).to match(/^# This file is generated by Chef for/)
to match(/^# This file is generated by Chef for/)
end end
it 'configures postfix to use the sasl_passwd file' do it 'configures postfix to use the sasl_passwd file' do
expect(file('/etc/postfix/main.cf').content). expect(file('/etc/postfix/main.cf').content).to match(/^\s*smtp_sasl_password_maps\s*=.*#{sasl_passwd_file}\s*$/)
to match(/^\s*smtp_sasl_password_maps\s*=.*#{sasl_passwd_file}\s*$/)
end end
end end