[COOK-4619] - no way to unset recipient_delimiter
Signed-off-by: Sean OMeara <someara@opscode.com>
This commit is contained in:
parent
f27480fa4c
commit
0a42b0722b
@ -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
4
.rubocop.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Encoding:
|
||||||
|
Enabled: False
|
||||||
|
LineLength:
|
||||||
|
Max: 200
|
@ -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.
|
||||||
|
@ -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'
|
||||||
|
@ -11,7 +11,7 @@ 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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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']
|
||||||
|
@ -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'
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
6
test/fixtures/cookbooks/fake/metadata.rb
vendored
6
test/fixtures/cookbooks/fake/metadata.rb
vendored
@ -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.'
|
||||||
|
@ -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'
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user