one for-loop for all of the mappings

This commit is contained in:
Florian Ermisch 2017-08-24 13:10:54 +02:00 committed by Wurzel Kollektiv
parent 136e02a61c
commit 8eed254773
1 changed files with 14 additions and 9 deletions

View File

@ -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 -%}