Merge branch 'master' of git://github.com/voroniys/postfix into voroniys-master

This commit is contained in:
Tim Smith
2017-01-17 23:50:55 -08:00
12 changed files with 574 additions and 150 deletions

View File

@@ -57,3 +57,15 @@ end
if node['postfix']['use_virtual_aliases_domains']
node.default_unless['postfix']['main']['virtual_alias_domains'] = ["#{node['postfix']['virtual_alias_domains_db_type']}:#{node['postfix']['virtual_alias_domains_db']}"]
end
if node['postfix']['use_relay_restirictions_maps']
default['postfix']['main']['smtpd_relay_restrictions'] = "hash:#{node['postfix']['relay_restrictions_db']}, reject"
end
if node['postfix']['master']['maildrop']['active']
node.default_unless['postfix']['main']['maildrop_destination_recipient_limit'] = 1
end
if node['postfix']['master']['cyrus']['active']
node.default_unless['postfix']['main']['cyrus_destination_recipient_limit'] = 1
end

View File

@@ -99,7 +99,7 @@ unless node['postfix']['smtp_generic_map_entries'].empty?
template "#{node['postfix']['conf_dir']}/smtp_generic" do
owner 'root'
group node['root_group']
mode '0644'
mode '0644'
notifies :run, 'execute[update-postfix-smtp_generic]'
notifies :reload, 'service[postfix]'
end

View File

@@ -1,4 +1,4 @@
# Copyright:: 2012-2016, Chef Software, Inc.
# Copyright:: Copyright 2012-2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ execute 'update-postfix-aliases' do
command 'newaliases'
environment PATH: "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
# On FreeBSD, /usr/sbin/newaliases is the sendmail command, and it's in the path before postfix's /usr/local/bin/newaliases
environment ({ 'PATH' => "/usr/local/bin:#{ENV['PATH']}" }) if platform_family?('freebsd') # rubocop: disable Lint/ParenthesesAsGroupedExpression
environment('PATH' => "/usr/local/bin:#{ENV['PATH']}") if platform_family?('freebsd')
action :nothing
end

View File

@@ -19,9 +19,7 @@
include_recipe 'postfix::_common'
if node['postfix']['main']['smtp_sasl_auth_enable'] == 'yes'
include_recipe 'postfix::sasl_auth'
end
include_recipe 'postfix::sasl_auth' if node['postfix']['main']['smtp_sasl_auth_enable'] == 'yes'
include_recipe 'postfix::aliases' if node['postfix']['use_alias_maps']
@@ -29,14 +27,10 @@ include_recipe 'postfix::transports' if node['postfix']['use_transport_maps']
include_recipe 'postfix::access' if node['postfix']['use_access_maps']
if node['postfix']['use_virtual_aliases']
include_recipe 'postfix::virtual_aliases'
end
include_recipe 'postfix::virtual_aliases' if node['postfix']['use_virtual_aliases']
if node['postfix']['use_virtual_aliases_domains']
include_recipe 'postfix::virtual_aliases_domains'
end
include_recipe 'postfix::virtual_aliases_domains' if node['postfix']['use_virtual_aliases_domains']
if node['postfix']['use_relay_restrictions_maps']
include_recipe 'postfix::relay_restrictions'
end
include_recipe 'postfix::relay_restrictions' if node['postfix']['use_relay_restrictions_maps']
include_recipe 'postfix::maps' if node['postfix']['maps']

47
recipes/maps.rb Normal file
View File

@@ -0,0 +1,47 @@
# encoding: utf-8
# Copyright:: Copyright (c) 2012, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
node['postfix']['maps'].each do |type, maps|
if node['platform_family'] == 'debian'
package "postfix-#{type}" if %w(pgsql mysql ldap cdb).include?(type)
end
if %w(pgsql mysql ldap memcache sqlite).include?(type)
separator = ' = '
else
separator = ' '
end
maps.each do |file, content|
execute "update-postmap-#{file}" do
command "postmap #{file}"
environment PATH: "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
action :nothing
end if %w(btree cdb dbm hash sdbm).include?(type)
template "#{file}-#{type}" do
path file
source 'maps.erb'
only_if "postconf -m | grep -q #{type}"
variables(
map: content,
separator: separator
)
if %w(btree cdb dbm hash sdbm).include?(type)
notifies :run, "execute[update-postmap-#{file}]"
end
notifies :restart, 'service[postfix]'
end
end
end