allows to rewrite outgoing address.

In my development env i want to make sure nobody can send a mail to a wrong address. So all outgoing mails are changed.

Signed-off-by: Bram Gillemon <bram@gillemon.be>
This commit is contained in:
Bram Gillemon 2017-07-28 13:40:50 +02:00
parent 7df2c36125
commit ca7b0033e9
5 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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"

View 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? %>