[COOK-3328] Refactor main.cf template and attributes

Signed-off-by: Seth Vargo <sethvargo@gmail.com>
This commit is contained in:
Eric G. Wolfe
2013-08-24 14:04:22 -04:00
committed by Seth Vargo
parent 3d18ce0e39
commit 0108248ac4
10 changed files with 193 additions and 262 deletions

View File

@@ -3,66 +3,17 @@
# Configured as <%= node['postfix']['mail_type'] %>
###
biff = no
append_dot_mydomain = no
smtpd_use_tls = <%= node['postfix']['smtpd_use_tls'] %>
<% if node['postfix']['smtpd_use_tls'] == "yes" -%>
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
<% end -%>
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_sasl_auth_enable = <%= node['postfix']['smtp_sasl_auth_enable'] %>
<% if node['postfix']['smtp_sasl_auth_enable'] == "yes" -%>
smtp_sasl_password_maps = <%= node['postfix']['smtp_sasl_password_maps'] %>
smtp_sasl_security_options = <%= node['postfix']['smtp_sasl_security_options'] %>
smtp_tls_CAfile = <%= node['postfix']['smtp_tls_cafile'] %>
smtp_use_tls = <%= node['postfix']['smtp_use_tls'] %>
<% end -%>
myhostname = <%= node['postfix']['myhostname'] %>
<% if node['postfix']['mydomain'] %>
mydomain = <%= node['postfix']['mydomain'] %>
<% end -%>
myorigin = <%= node['postfix']['myorigin'] %>
smtpd_banner = $myhostname ESMTP $mail_name
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = <%= node['postfix']['myhostname'] %>, <%= node['hostname'] %>, localhost.localdomain, localhost
<% if node['postfix']['mail_type'] == "master" -%>
relayhost =
mynetworks = <%= node['postfix']['mail_relay_networks'] %>
inet_interfaces = <%= node['postfix']['inet_interfaces'] || 'all' %>
<% else -%>
relayhost = <%= node['postfix']['relayhost'] %>
mynetworks = <%= node['postfix']['mail_relay_networks'] %>
inet_interfaces = <%= node['postfix']['inet_interfaces'] || 'loopback-only' %>
<% end -%>
<% if node['postfix']['use_procmail'] -%>
mailbox_command = /usr/bin/procmail -a "$EXTENSION"
<% end -%>
mailbox_size_limit = 0
recipient_delimiter = +
milter_default_action = <%= node['postfix']['milter_default_action'] %>
milter_protocol = <%= node['postfix']['milter_protocol'] %>
smtpd_milters = <%= node['postfix']['smtpd_milters'] %>
non_smtpd_milters = <%= node['postfix']['non_smtpd_milters'] %>
<% unless node['postfix']['sender_canonical_classes'].nil? -%>
sender_canonical_classes = <%= node['postfix']['sender_canonical_classes'] %>
<% end -%>
<% unless node['postfix']['recipient_canonical_classes'].nil? -%>
recipient_canonical_classes = <%= node['postfix']['recipient_canonical_classes'] %>
<% end -%>
<% unless node['postfix']['canonical_classes'].nil? -%>
canonical_classes = <%= node['postfix']['canonical_classes'] %>
<% end -%>
<% unless node['postfix']['sender_canonical_maps'].nil? -%>
sender_canonical_maps = <%= node['postfix']['sender_canonical_maps'] %>
<% end -%>
<% unless node['postfix']['recipient_canonical_maps'].nil? -%>
recipient_canonical_maps = <%= node['postfix']['recipient_canonical_maps'] %>
<% end -%>
<% unless node['postfix']['canonical_maps'].nil? -%>
canonical_maps = <%= node['postfix']['canonical_maps'] %>
<% @settings.sort.map do |key, value| -%>
<% if value.kind_of? Array -%>
<%= "#{key} = " -%>
<% value.each do |item| -%>
<% if value.last == item -%>
<%= item %>
<% else -%>
<%= "#{item}, " -%>
<% end -%>
<% end -%>
<% else -%>
<%= "#{key} = #{value}"%>
<% end -%>
<% end -%>

View File

@@ -7,10 +7,12 @@
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
smtp inet n - n - - smtpd
#submission inet n - n - - smtpd
# -o smtpd_enforce_tls=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticated,reject
<% if @settings['submission'] -%>
submission inet n - n - - smtpd
-o smtpd_enforce_tls=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
<% end -%>
#smtps inet n - n - - smtpd
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes

View File

@@ -1,2 +1,2 @@
# This file is generated by Chef for <%= node['fqdn'] %>
<%= node['postfix']['relayhost'] %> <%= node['postfix']['smtp_sasl_user_name'] %>:<%= node['postfix']['smtp_sasl_passwd'] %>
<%= node['postfix']['main']['relayhost'] %> <%= @settings['smtp_sasl_user_name'] %>:<%= @settings['smtp_sasl_passwd'] %>