#64 - add smtp_generic maps configuration option

Signed-off-by: Sean OMeara <someara@opscode.com>
This commit is contained in:
skubriev 2014-06-11 13:50:20 -04:00 committed by Sean OMeara
parent 3dd026f899
commit e2d49e10e9
4 changed files with 43 additions and 1 deletions

View File

@ -58,6 +58,18 @@ This change in namespace to `node['postfix']['main']` should allow for greater f
- `node['postfix']['main']['relayhost']` - Set to empty string - `node['postfix']['main']['relayhost']` - Set to empty string
- `node['postfix']['sasl']['smtp_sasl_user_name']` - SASL user to authenticate as. Default empty - `node['postfix']['sasl']['smtp_sasl_user_name']` - SASL user to authenticate as. Default empty
- `node['postfix']['sasl']['smtp_sasl_passwd']` - SASL password to use. Default empty. - `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.
Example of json role config, for setup *_map_entries:
`postfix : {`
`...`
`"smtp_generic_map_entries" : { "root@youinternaldomain.local" : "admin@example.com", "admin@youinternaldomain.local" : "admin@example.com" }`
`}`
### master.cf template attributes ### master.cf template attributes
* `node['postfix']['master']['submission'] - Whether to use submission (TCP 587) daemon. (true/false); default false * `node['postfix']['master']['submission'] - Whether to use submission (TCP 587) daemon. (true/false); default false

View File

@ -24,6 +24,7 @@ default['postfix']['aliases'] = {}
default['postfix']['main_template_source'] = 'postfix' default['postfix']['main_template_source'] = 'postfix'
default['postfix']['master_template_source'] = 'postfix' default['postfix']['master_template_source'] = 'postfix'
default['postfix']['sender_canonical_map_entries'] = {} default['postfix']['sender_canonical_map_entries'] = {}
default['postfix']['smtp_generic_map_entries'] = {}
case node['platform'] case node['platform']
when 'smartos' when 'smartos'

View File

@ -89,7 +89,26 @@ unless node['postfix']['sender_canonical_map_entries'].empty?
end end
end end
%w(main master).each do |cfg| execute 'update-postfix-smtp_generic' do
command "postmap #{node['postfix']['conf_dir']}/smtp_generic"
action :nothing
end
if !node['postfix']['smtp_generic_map_entries'].empty?
template "#{node['postfix']['conf_dir']}/smtp_generic" do
owner 'root'
group 0
mode '0644'
notifies :run, 'execute[update-postfix-smtp_generic]'
notifies :reload, 'service[postfix]'
end
if !node['postfix']['main'].key?('smtp_generic_maps')
node.set['postfix']['main']['smtp_generic_maps'] = "hash:#{node['postfix']['conf_dir']}/smtp_generic"
end
end
%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

@ -0,0 +1,10 @@
#
# This file is generated by Chef for <%= node['fqdn'] %>
#
# Local changes will be overwritten
#
# See man 5 generic for format
<% node['postfix']['smtp_generic_map_entries'].each do |name, value| %>
<%= name %> <%= value %>
<% end unless node['postfix']['smtp_generic_map_entries'].nil? %>