diff --git a/README.md b/README.md index e4be15b..51a277c 100644 --- a/README.md +++ b/README.md @@ -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']['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']['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 * `node['postfix']['master']['submission'] - Whether to use submission (TCP 587) daemon. (true/false); default false diff --git a/attributes/default.rb b/attributes/default.rb index b054420..e575c61 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -24,6 +24,7 @@ default['postfix']['aliases'] = {} default['postfix']['main_template_source'] = 'postfix' default['postfix']['master_template_source'] = 'postfix' default['postfix']['sender_canonical_map_entries'] = {} +default['postfix']['smtp_generic_map_entries'] = {} case node['platform'] when 'smartos' diff --git a/recipes/default.rb b/recipes/default.rb index 07fdf8d..b6e058d 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -89,7 +89,26 @@ unless node['postfix']['sender_canonical_map_entries'].empty? 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 source "#{cfg}.cf.erb" owner 'root' diff --git a/templates/default/smtp_generic.erb b/templates/default/smtp_generic.erb new file mode 100644 index 0000000..7aa5d64 --- /dev/null +++ b/templates/default/smtp_generic.erb @@ -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? %>