From 51d2e5936d82064cb9e1d191d543bf0fae4752cf Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Fri, 2 Oct 2015 23:11:27 +0200 Subject: [PATCH 1/3] Fix excessive whitespace stripping --- postfix/files/main.cf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postfix/files/main.cf b/postfix/files/main.cf index 421dec6..3e1136c 100644 --- a/postfix/files/main.cf +++ b/postfix/files/main.cf @@ -41,8 +41,8 @@ {%- if config.get('smtpd_sasl_auth_enable', 'yes') == 'yes' %} # SASL parameters (http://www.postfix.org/SASL_README.html) -{%- do relay_restrictions.append('permit_sasl_authenticated') -%} -{%- do recipient_restrictions.append('permit_sasl_authenticated') -%} +{%- do relay_restrictions.append('permit_sasl_authenticated') %} +{%- do recipient_restrictions.append('permit_sasl_authenticated') %} {{ set_parameter('smtpd_sasl_auth_enable') }} {{ set_parameter('smtpd_sasl_path', 'smtpd') }} {{ set_parameter('smtpd_sasl_type', 'cyrus') }} From e20aeb5d8954d6ee67141b7278f3707360cf992e Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Fri, 2 Oct 2015 23:11:50 +0200 Subject: [PATCH 2/3] Fix handling of smtpd_sasl_auth_enable Defaults to yes but will not write yes unless a default is provided to set_parameter. --- postfix/files/main.cf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postfix/files/main.cf b/postfix/files/main.cf index 3e1136c..9299055 100644 --- a/postfix/files/main.cf +++ b/postfix/files/main.cf @@ -43,7 +43,7 @@ # SASL parameters (http://www.postfix.org/SASL_README.html) {%- do relay_restrictions.append('permit_sasl_authenticated') %} {%- do recipient_restrictions.append('permit_sasl_authenticated') %} -{{ set_parameter('smtpd_sasl_auth_enable') }} +{{ set_parameter('smtpd_sasl_auth_enable', 'yes') }} {{ set_parameter('smtpd_sasl_path', 'smtpd') }} {{ set_parameter('smtpd_sasl_type', 'cyrus') }} {{ set_parameter('smtpd_sasl_security_options', ['noanonymous', 'noplaintext']) }} From 00d7bb582aa0ed130fcbeb8c8e25174e703bf7ad Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Fri, 2 Oct 2015 23:12:37 +0200 Subject: [PATCH 3/3] Add a macro to deal with postmap'ed files, closes: #29 --- postfix/init.sls | 68 ++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 46 deletions(-) diff --git a/postfix/init.sls b/postfix/init.sls index 31a305f..34b6dda 100644 --- a/postfix/init.sls +++ b/postfix/init.sls @@ -12,6 +12,25 @@ postfix: - watch: - pkg: postfix +{%- macro postmap_file(filename) %} +{%- set file_path = '/etc/postfix/' ~ filename %} +postmap_{{ filename }}: + file.managed: + - name: {{ file_path }} + - source: salt://postfix/{{ filename }} + - user: root + - group: root + - mode: 0644 + - template: jinja + - require: + - pkg: postfix + cmd.wait: + - name: /usr/sbin/postmap {{ file_path }} + - cwd: / + - watch: + - file: {{ file_path }} +{%- endmacro %} + # manage /etc/aliases if data found in pillar {% if 'aliases' in pillar.get('postfix', '') %} {{ postfix.aliases_file }}: @@ -34,58 +53,15 @@ run-newaliases: # manage /etc/postfix/virtual if data found in pillar {% if 'virtual' in pillar.get('postfix', '') %} -/etc/postfix/virtual: - file.managed: - - source: salt://postfix/virtual - - user: root - - group: root - - mode: 644 - - template: jinja - - require: - - pkg: postfix - -run-postmap: - cmd.wait: - - name: /usr/sbin/postmap /etc/postfix/virtual - - cwd: / - - watch: - - file: /etc/postfix/virtual +{{ postmap_file('virtual') }} {% endif %} # manage /etc/postfix/sasl_passwd if data found in pillar {% if 'sasl_passwd' in pillar.get('postfix', '') %} -/etc/postfix/sasl_passwd: - file.managed: - - source: salt://postfix/sasl_passwd - - user: root - - group: root - - mode: 644 - - template: jinja - - require: - - pkg: postfix - - cmd.wait: - - name: /usr/sbin/postmap /etc/postfix/sasl_passwd - - cwd: / - - watch: - - file: /etc/postfix/sasl_passwd +{{ postmap_file('sasl_passwd') }} {% endif %} # manage /etc/postfix/sender_canonical if data found in pillar {% if 'sender_canonical' in pillar.get('postfix', '') %} -/etc/postfix/sender_canonical: - file.managed: - - source: salt://postfix/sender_canonical - - user: root - - group: root - - mode: 644 - - template: jinja - - require: - - pkg: postfix - - cmd.wait: - - name: /usr/sbin/postmap /etc/postfix/sender_canonical - - cwd: / - - watch: - - file: /etc/postfix/sender_canonical +{{ postmap_file('sender_canonical') }} {% endif %}