add optional context variable "colon" to mapping.j2 for aliases file

This commit is contained in:
Florian Ermisch 2017-08-24 12:49:05 +02:00 committed by Wurzel Kollektiv
parent 099d84ab73
commit d51f60647a
3 changed files with 9 additions and 6 deletions

View File

@ -1,3 +0,0 @@
# Managed by config management
# See man 5 aliases for format
{{pillar['postfix']['aliases']['content']}}

View File

@ -1,11 +1,14 @@
# Managed by config management
{%- if colon is not defined %}
{%- set colon = False %}
{%- endif %}
{%- macro format_value(key, value) %}
{#- Some settings, like virtual_alias_maps can take multiple values. Handle this case. -#}
{%- if value is iterable and value is not string -%}
{{ key }} {{ value|join(", ") }}
{{ key }}{% if colon %}:{% endif %} {{ value|join(", ") }}
{%- else -%}
{{ key }} {{ value }}
{{ key }}{% if colon %}:{% endif %} {{ value }}
{%- endif -%}
{%- endmacro %}

View File

@ -31,11 +31,14 @@ postfix:
postfix_alias_database:
file.managed:
- name: {{ file_path }}
- source: salt://postfix/aliases
- source: salt://postfix/files/mapping.j2
- user: root
- group: {{ postfix.root_grp }}
- mode: 644
- template: jinja
- context:
data: {{ salt['pillar.get']('postfix:aliases:present') }}
colon: True
- require:
- pkg: postfix
{%- if need_newaliases %}