diff --git a/postfix/config.sls b/postfix/config.sls index 0554677..49cc9dd 100644 --- a/postfix/config.sls +++ b/postfix/config.sls @@ -1,19 +1,21 @@ include: - postfix -/etc/postfix: +{% from "postfix/map.jinja" import postfix with context %} + +{{ postfix.config_dir }}: file.directory: - - user: root - - group: root + - user: {{ postfix.root_user }} + - group: {{ postfix.root_group }} - dir_mode: 755 - file_mode: 644 - makedirs: True -/etc/postfix/main.cf: +{{ postfix.config_dir }}/main.cf: file.managed: - source: salt://postfix/files/main.cf - - user: root - - group: root + - user: {{ postfix.root_user }} + - group: {{ postfix.root_group }} - mode: 644 - require: - pkg: postfix @@ -22,10 +24,10 @@ include: - template: jinja {% if 'vmail' in pillar.get('postfix', '') %} -/etc/postfix/virtual_alias_maps.cf: +{{ postfix.config_dir }}/virtual_alias_maps.cf: file.managed: - source: salt://postfix/files/virtual_alias_maps.cf - - user: root + - user: {{ postfix.root_user }} - group: postfix - mode: 640 - require: @@ -34,10 +36,10 @@ include: - service: postfix - template: jinja -/etc/postfix/virtual_mailbox_domains.cf: +{{ postfix.config_dir }}/virtual_mailbox_domains.cf: file.managed: - source: salt://postfix/files/virtual_mailbox_domains.cf - - user: root + - user: {{ postfix.root_user }} - group: postfix - mode: 640 - require: @@ -46,10 +48,10 @@ include: - service: postfix - template: jinja -/etc/postfix/virtual_mailbox_maps.cf: +{{ postfix.config_dir }}/virtual_mailbox_maps.cf: file.managed: - source: salt://postfix/files/virtual_mailbox_maps.cf - - user: root + - user: {{ postfix.root_user }} - group: postfix - mode: 640 - require: @@ -60,11 +62,11 @@ include: {% endif %} {% if salt['pillar.get']('postfix:manage_master_config', True) %} -/etc/postfix/master.cf: +{{ postfix.config_dir }}/master.cf: file.managed: - source: salt://postfix/files/master.cf - - user: root - - group: root + - user: {{ postfix.root_user }} + - group: {{ postfix.root_group }} - mode: 644 - require: - pkg: postfix @@ -74,11 +76,11 @@ include: {% endif %} {% if 'transport' in pillar.get('postfix', '') %} -/etc/postfix/transport: +{{ postfix.config_dir }}/transport: file.managed: - source: salt://postfix/files/transport - - user: root - - group: root + - user: {{ postfix.root_user }} + - group: {{ postfix.root_group }} - mode: 644 - require: - pkg: postfix @@ -88,10 +90,10 @@ include: run-postmap: cmd.wait: - - name: /usr/sbin/postmap /etc/postfix/transport + - name: /usr/sbin/postmap {{ postfix.config_dir }}/transport - cwd: / - watch: - - file: /etc/postfix/transport + - file: {{ postfix.config_dir }}/transport {% endif %} {%- for domain in salt['pillar.get']('postfix:certificates', {}).keys() %} @@ -99,7 +101,7 @@ run-postmap: postfix_{{ domain }}_ssl_certificate: file.managed: - - name: /etc/postfix/ssl/{{ domain }}.crt + - name: {{ postfix.config_dir }}/ssl/{{ domain }}.crt - makedirs: True - contents_pillar: postfix:certificates:{{ domain }}:public_cert - watch_in: @@ -107,7 +109,7 @@ postfix_{{ domain }}_ssl_certificate: postfix_{{ domain }}_ssl_key: file.managed: - - name: /etc/postfix/ssl/{{ domain }}.key + - name: {{ postfix.config_dir }}/ssl/{{ domain }}.key - mode: 600 - makedirs: True - contents_pillar: postfix:certificates:{{ domain }}:private_key diff --git a/postfix/defaults.yaml b/postfix/defaults.yaml index bbe615e..e870e0b 100644 --- a/postfix/defaults.yaml +++ b/postfix/defaults.yaml @@ -3,3 +3,5 @@ postfix: service: postfix aliases_file: /etc/aliases config_dir: /etc/postfix + root_user: root + root_group: root diff --git a/postfix/files/main.cf b/postfix/files/main.cf index 4d686bc..5608c21 100644 --- a/postfix/files/main.cf +++ b/postfix/files/main.cf @@ -98,15 +98,15 @@ policy-spf_time_limit = {{ policyd_spf.get('time_limit', '3600s') }} {{ set_parameter('smtpd_recipient_restrictions', recipient_restrictions) }} {% if 'virtual' in pillar.get('postfix','') %} -virtual_alias_maps = hash:/etc/postfix/virtual +virtual_alias_maps = hash:{{ postfix.config_dir }}/virtual {% endif %} {% if 'sasl_passwd' in pillar.get('postfix','') %} -smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd +smtp_sasl_password_maps = hash:{{ postfix.config_dir }}/sasl_passwd {% endif %} {% if 'sender_canonical' in pillar.get('postfix','') %} -sender_canonical_maps = hash:/etc/postfix/sender_canonical +sender_canonical_maps = hash:{{ postfix.config_dir }}/sender_canonical {% endif %} {# Accept arbitrary parameters -#} diff --git a/postfix/osmap.yaml b/postfix/osmap.yaml index d9d0ccf..32c863e 100644 --- a/postfix/osmap.yaml +++ b/postfix/osmap.yaml @@ -5,6 +5,10 @@ Debian: pcre_pkg: postfix-pcre mysql_pkg: postfix-mysql +FreeBSD: + config_dir: /usr/local/etc/postfix + root_group: wheel + Gentoo: package: mail-mta/postfix policyd_spf_pkg: mail-filter/pypolicyd-spf