postfix-formula/postfix/files/virtual_alias_maps.cf

25 lines
950 B
CFEngine3

{%- if 'mysql' in salt['pillar.get']('postfix:config:virtual_alias_maps', '') %}
{%- set config = salt['pillar.get']('postfix:mysql:virtual_alias_maps', {}) -%}
{%- for key,value in salt['pillar.get']('postfix:vmail').items() %}
{{ key }} = {{ value }}
{%- endfor %}
query = SELECT {{ config.select_field|default('destination') }} FROM {{ config.table|default('virtual_aliases') }} WHERE {{ config.where_field|default('email') }}='%s'
{%- else %}
{% set config = salt['pillar.get']('postfix:vmail', {}) -%}
{% macro set_parameter(parameter, default=None) -%}
{% set value = config.get(parameter, default) -%}
{% if value is not none -%}
{{ parameter }} = {{ value }}
{% endif -%}
{% endmacro -%}
{# Accept arbitrary parameters -#}
{% for parameter in config -%}
{{ set_parameter(parameter) }}
{% endfor -%}
{{ set_parameter('table', 'alias') }}
{{ set_parameter('select_field', 'goto') }}
{{ set_parameter('where_field', 'address') }}
{%- endif %}