diff --git a/postfix/files/main.cf b/postfix/files/main.cf index 4d686bc..219ee6b 100644 --- a/postfix/files/main.cf +++ b/postfix/files/main.cf @@ -97,17 +97,22 @@ policy-spf_time_limit = {{ policyd_spf.get('time_limit', '3600s') }} {%- endif %} {{ set_parameter('smtpd_recipient_restrictions', recipient_restrictions) }} -{% if 'virtual' in pillar.get('postfix','') %} -virtual_alias_maps = hash:/etc/postfix/virtual -{% endif %} +{# From init.sls #} +{%- set default_database_type = salt['pillar.get']('postfix:config:default_database_type', 'hash') %} -{% if 'sasl_passwd' in pillar.get('postfix','') %} -smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd -{% endif %} +{%- for mapping, data in salt['pillar.get']('postfix:mapping', {}).items() %} + {%- set file_path = salt['pillar.get']('postfix:config:' ~ mapping) %} + {%- if ':' in file_path %} + {%- set file_type, file_path = file_path.split(':') %} + {%- else %} + {%- set file_type = default_database_type %} + {%- endif %} + {%- if not file_path.startswith('/') %} + {%- set file_path = postfix.config_path ~ '/' ~ file_path %} + {%- endif %} -{% if 'sender_canonical' in pillar.get('postfix','') %} -sender_canonical_maps = hash:/etc/postfix/sender_canonical -{% endif %} +{{ mapping }} = {{ file_type }}:{{ file_path }} +{% endfor %} {# Accept arbitrary parameters -#} {% for parameter in config -%}