Compare commits

...

2 Commits

Author SHA1 Message Date
Alexander Weidinger
c1ed7f30b7 FreeBSD support 2017-12-08 04:16:18 +01:00
Alexander Weidinger
f5990cfbfc defaults.yaml and osmap.yaml 2017-12-08 03:53:26 +01:00
5 changed files with 74 additions and 61 deletions

View File

@ -1,19 +1,21 @@
include: include:
- postfix - postfix
/etc/postfix: {% from "postfix/map.jinja" import postfix with context %}
{{ postfix.config_dir }}:
file.directory: file.directory:
- user: root - user: {{ postfix.root_user }}
- group: root - group: {{ postfix.root_group }}
- dir_mode: 755 - dir_mode: 755
- file_mode: 644 - file_mode: 644
- makedirs: True - makedirs: True
/etc/postfix/main.cf: {{ postfix.config_dir }}/main.cf:
file.managed: file.managed:
- source: salt://postfix/files/main.cf - source: salt://postfix/files/main.cf
- user: root - user: {{ postfix.root_user }}
- group: root - group: {{ postfix.root_group }}
- mode: 644 - mode: 644
- require: - require:
- pkg: postfix - pkg: postfix
@ -22,10 +24,10 @@ include:
- template: jinja - template: jinja
{% if 'vmail' in pillar.get('postfix', '') %} {% if 'vmail' in pillar.get('postfix', '') %}
/etc/postfix/virtual_alias_maps.cf: {{ postfix.config_dir }}/virtual_alias_maps.cf:
file.managed: file.managed:
- source: salt://postfix/files/virtual_alias_maps.cf - source: salt://postfix/files/virtual_alias_maps.cf
- user: root - user: {{ postfix.root_user }}
- group: postfix - group: postfix
- mode: 640 - mode: 640
- require: - require:
@ -34,10 +36,10 @@ include:
- service: postfix - service: postfix
- template: jinja - template: jinja
/etc/postfix/virtual_mailbox_domains.cf: {{ postfix.config_dir }}/virtual_mailbox_domains.cf:
file.managed: file.managed:
- source: salt://postfix/files/virtual_mailbox_domains.cf - source: salt://postfix/files/virtual_mailbox_domains.cf
- user: root - user: {{ postfix.root_user }}
- group: postfix - group: postfix
- mode: 640 - mode: 640
- require: - require:
@ -46,10 +48,10 @@ include:
- service: postfix - service: postfix
- template: jinja - template: jinja
/etc/postfix/virtual_mailbox_maps.cf: {{ postfix.config_dir }}/virtual_mailbox_maps.cf:
file.managed: file.managed:
- source: salt://postfix/files/virtual_mailbox_maps.cf - source: salt://postfix/files/virtual_mailbox_maps.cf
- user: root - user: {{ postfix.root_user }}
- group: postfix - group: postfix
- mode: 640 - mode: 640
- require: - require:
@ -60,11 +62,11 @@ include:
{% endif %} {% endif %}
{% if salt['pillar.get']('postfix:manage_master_config', True) %} {% if salt['pillar.get']('postfix:manage_master_config', True) %}
/etc/postfix/master.cf: {{ postfix.config_dir }}/master.cf:
file.managed: file.managed:
- source: salt://postfix/files/master.cf - source: salt://postfix/files/master.cf
- user: root - user: {{ postfix.root_user }}
- group: root - group: {{ postfix.root_group }}
- mode: 644 - mode: 644
- require: - require:
- pkg: postfix - pkg: postfix
@ -74,11 +76,11 @@ include:
{% endif %} {% endif %}
{% if 'transport' in pillar.get('postfix', '') %} {% if 'transport' in pillar.get('postfix', '') %}
/etc/postfix/transport: {{ postfix.config_dir }}/transport:
file.managed: file.managed:
- source: salt://postfix/files/transport - source: salt://postfix/files/transport
- user: root - user: {{ postfix.root_user }}
- group: root - group: {{ postfix.root_group }}
- mode: 644 - mode: 644
- require: - require:
- pkg: postfix - pkg: postfix
@ -88,10 +90,10 @@ include:
run-postmap: run-postmap:
cmd.wait: cmd.wait:
- name: /usr/sbin/postmap /etc/postfix/transport - name: /usr/sbin/postmap {{ postfix.config_dir }}/transport
- cwd: / - cwd: /
- watch: - watch:
- file: /etc/postfix/transport - file: {{ postfix.config_dir }}/transport
{% endif %} {% endif %}
{%- for domain in salt['pillar.get']('postfix:certificates', {}).keys() %} {%- for domain in salt['pillar.get']('postfix:certificates', {}).keys() %}
@ -99,7 +101,7 @@ run-postmap:
postfix_{{ domain }}_ssl_certificate: postfix_{{ domain }}_ssl_certificate:
file.managed: file.managed:
- name: /etc/postfix/ssl/{{ domain }}.crt - name: {{ postfix.config_dir }}/ssl/{{ domain }}.crt
- makedirs: True - makedirs: True
- contents_pillar: postfix:certificates:{{ domain }}:public_cert - contents_pillar: postfix:certificates:{{ domain }}:public_cert
- watch_in: - watch_in:
@ -107,7 +109,7 @@ postfix_{{ domain }}_ssl_certificate:
postfix_{{ domain }}_ssl_key: postfix_{{ domain }}_ssl_key:
file.managed: file.managed:
- name: /etc/postfix/ssl/{{ domain }}.key - name: {{ postfix.config_dir }}/ssl/{{ domain }}.key
- mode: 600 - mode: 600
- makedirs: True - makedirs: True
- contents_pillar: postfix:certificates:{{ domain }}:private_key - contents_pillar: postfix:certificates:{{ domain }}:private_key

7
postfix/defaults.yaml Normal file
View File

@ -0,0 +1,7 @@
postfix:
package: postfix
service: postfix
aliases_file: /etc/aliases
config_dir: /etc/postfix
root_user: root
root_group: root

View File

@ -98,15 +98,15 @@ policy-spf_time_limit = {{ policyd_spf.get('time_limit', '3600s') }}
{{ set_parameter('smtpd_recipient_restrictions', recipient_restrictions) }} {{ set_parameter('smtpd_recipient_restrictions', recipient_restrictions) }}
{% if 'virtual' in pillar.get('postfix','') %} {% if 'virtual' in pillar.get('postfix','') %}
virtual_alias_maps = hash:/etc/postfix/virtual virtual_alias_maps = hash:{{ postfix.config_dir }}/virtual
{% endif %} {% endif %}
{% if 'sasl_passwd' in pillar.get('postfix','') %} {% 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 %} {% endif %}
{% if 'sender_canonical' in pillar.get('postfix','') %} {% 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 %} {% endif %}
{# Accept arbitrary parameters -#} {# Accept arbitrary parameters -#}

View File

@ -1,36 +1,12 @@
{% set postfix = salt['grains.filter_by']({ {% import_yaml "postfix/defaults.yaml" as defaults %}
'Debian': { {% import_yaml "postfix/osmap.yaml" as osmap %}
'package': 'postfix',
'policyd_spf_pkg': 'postfix-policyd-spf-python', {% set postfix = salt['grains.filter_by'](
'postsrsd_pkg': 'postsrsd', defaults,
'postgrey_pkg': 'postgrey', merge=salt['grains.filter_by'](
'pcre_pkg': 'postfix-pcre', osmap,
'mysql_pkg': 'postfix-mysql', grain='os',
'service': 'postfix', merge=salt['pillar.get']('postfix:lookup', {}),
'aliases_file': '/etc/aliases', ),
}, base='postfix')
'Gentoo': { %}
'package': 'mail-mta/postfix',
'policyd_spf_pkg': 'mail-filter/pypolicyd-spf',
'postsrsd_pkg': 'mail-filter/postsrsd',
'postgrey_pkg': 'mail-filter/postgrey',
'service': 'postfix',
'aliases_file': '/etc/mail/aliases',
},
'RedHat': {
'package': 'postfix',
'policyd_spf_pkg': 'pypolicyd-spf',
'postsrsd_pkg': 'postsrsd',
'postgrey_pkg': 'postgrey',
'service': 'postfix',
'aliases_file': '/etc/aliases',
},
'Arch' : {
'package': 'postfix',
'policyd_spf_pkg': 'python-postfix-policyd-spf',
'postsrsd_pkg': 'postsrsd',
'postgrey_pkg': 'postgrey',
'service': 'postfix',
'aliases_file': '/etc/aliases',
},
}, merge=salt['pillar.get']('postfix:lookup')) %}

28
postfix/osmap.yaml Normal file
View File

@ -0,0 +1,28 @@
Debian:
policyd_spf_pkg: postfix-policyd-spf-python
postsrsd_pkg: postsrsd
postgrey_pkg: postgrey
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
postsrsd_pkg: mail-filter/postsrsd
postgrey_pkg: mail-filter/postgrey
aliases_file: /etc/mail/aliases
RedHat:
policyd_spf_pkg: pypolicyd-spf
postsrsd_pkg: postsrsd
postgrey_pkg: postgrey
Arch:
policyd_spf_pkg: python-postfix-policyd-spf
postsrsd_pkg: postsrsd
postgrey_pkg: postgrey