Merge pull request #140 from X-plose/recipient_canonical_maps
Recipient canonical maps
This commit is contained in:
commit
0992e17e68
@ -105,3 +105,11 @@ suites:
|
||||
sasl:
|
||||
smtp_sasl_user_name: "kitchenuser"
|
||||
smtp_sasl_passwd: "not-a-real-thing"
|
||||
|
||||
- name: canonical
|
||||
run_list:
|
||||
- recipe[postfix]
|
||||
attributes:
|
||||
postfix:
|
||||
recipient_canonical_map_entries:
|
||||
john: john@doe.com
|
@ -47,3 +47,12 @@ suites:
|
||||
sasl:
|
||||
smtp_sasl_user_name: "kitchenuser"
|
||||
smtp_sasl_passwd: "not-a-real-thing"
|
||||
|
||||
- name: canonical
|
||||
run_list:
|
||||
- recipe[postfix]
|
||||
attributes:
|
||||
postfix:
|
||||
recipient_canonical_map_entries:
|
||||
john: john@doe.com
|
||||
|
@ -23,6 +23,12 @@ env:
|
||||
- INSTANCE=default-centos-7
|
||||
- INSTANCE=default-ubuntu-1404
|
||||
- INSTANCE=default-ubuntu-1604
|
||||
- INSTANCE=canonical-centos-6
|
||||
- INSTANCE=canonical-centos-7
|
||||
- INSTANCE=canonical-debian-7
|
||||
- INSTANCE=canonical-debian-8
|
||||
- INSTANCE=canonical-ubuntu-1404
|
||||
- INSTANCE=canonical-ubuntu-1604
|
||||
|
||||
before_script:
|
||||
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
|
||||
|
@ -79,6 +79,8 @@ This change in namespace to `node['postfix']['main']` should allow for greater f
|
||||
- `node['postfix']['sasl']['smtp_sasl_passwd']` - SASL password to use. Default empty.
|
||||
- `node['postfix']['sender_canonical_map_entries']` - (hash with key value pairs); default not configured. Setup generic canonical maps. See `man 5 canonical`. If has at least one value, then will be enabled in config.
|
||||
- `node['postfix']['smtp_generic_map_entries']` - (hash with key value pairs); default not configured. Setup generic postfix maps. See `man 5 generic`. If has at least one value, then will be enabled in config.
|
||||
- `node['postfix']['recipient_canonical_map_entries']` - (hash with key value pairs); default not configured. Setup generic canonical maps. See `man 5 canonical`. If has at least one value, then will be enabled in config.
|
||||
|
||||
|
||||
Example of json role config, for setup *_map_entries:
|
||||
|
||||
|
@ -33,6 +33,7 @@ default['postfix']['main_template_source'] = 'postfix'
|
||||
default['postfix']['master_template_source'] = 'postfix'
|
||||
default['postfix']['sender_canonical_map_entries'] = {}
|
||||
default['postfix']['smtp_generic_map_entries'] = {}
|
||||
default['postfix']['recipient_canonical_map_entries'] = {}
|
||||
default['postfix']['access_db_type'] = 'hash'
|
||||
default['postfix']['aliases_db_type'] = 'hash'
|
||||
default['postfix']['transport_db_type'] = 'hash'
|
||||
|
@ -109,6 +109,25 @@ unless node['postfix']['smtp_generic_map_entries'].empty?
|
||||
end
|
||||
end
|
||||
|
||||
execute 'update-postfix-recipient_canonical' do
|
||||
command "postmap #{node['postfix']['conf_dir']}/recipient_canonical"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
unless node['postfix']['recipient_canonical_map_entries'].empty?
|
||||
template "#{node['postfix']['conf_dir']}/recipient_canonical" do
|
||||
owner 'root'
|
||||
group node['root_group']
|
||||
mode '0644'
|
||||
notifies :run, 'execute[update-postfix-recipient_canonical]'
|
||||
notifies :reload, 'service[postfix]'
|
||||
end
|
||||
|
||||
unless node['postfix']['main'].key?('recipient_canonical_maps')
|
||||
node.normal['postfix']['main']['recipient_canonical_maps'] = "hash:#{node['postfix']['conf_dir']}/recipient_canonical"
|
||||
end
|
||||
end
|
||||
|
||||
%w( main master ).each do |cfg|
|
||||
template "#{node['postfix']['conf_dir']}/#{cfg}.cf" do
|
||||
source "#{cfg}.cf.erb"
|
||||
|
9
templates/default/recipient_canonical.erb
Normal file
9
templates/default/recipient_canonical.erb
Normal file
@ -0,0 +1,9 @@
|
||||
#
|
||||
# Auto-generated by Chef.
|
||||
# Local modifications will be overwritten.
|
||||
#
|
||||
# See man 5 canonical for format
|
||||
|
||||
<% node['postfix']['recipient_canonical_map_entries'].each do |name, value| %>
|
||||
<%= name %> <%= value %>
|
||||
<% end unless node['postfix']['recipient_canonical_map_entries'].nil? %>
|
23
test/integration/canonical/serverspec/canonical_spec.rb
Normal file
23
test/integration/canonical/serverspec/canonical_spec.rb
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright:: 2012-2017, 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.
|
||||
#
|
||||
require_relative './spec_helper'
|
||||
|
||||
describe file('/etc/postfix/recipient_canonical.db') do
|
||||
it { should be_file }
|
||||
end
|
||||
|
||||
describe file('/etc/postfix/main.cf') do
|
||||
its(:content) { should match(%r{^\s*recipient_canonical_maps\s*=.*\/etc\/postfix\/recipient_canonical\s*$}) }
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user