Skip to content

Commit 19f5de8

Browse files
authored
Merge pull request #90 from alxwr/fix-89
Fix #89 by ignoring only keys which are actually used in Pillar 'postfix:mapping'
2 parents 84c6426 + fbaa2dc commit 19f5de8

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

pillar.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,24 @@ postfix:
235235
236236
237237
- singlealiasexample: [email protected]
238+
239+
240+
###
241+
#
242+
# Multiple virtual_alias_maps entries:
243+
#
244+
# You are free to define alternative mapping names
245+
# and use them as 'variables' in your Postfix config:
246+
# (Credit for the idea and the example goes to @roskens.)
247+
248+
postfix:
249+
config:
250+
virtual_alias_maps: $virtual_alias_1_maps $virtual_alias_2_maps
251+
virtual_alias_1_maps: hash:/etc/postfix/virtual
252+
virtual_alias_2_maps: pcre:/etc/postfix/virtual.pcre
253+
mapping:
254+
virtual_alias_1_maps:
255+
root:
256+
- me
257+
virtual_alias_2_maps:
258+
- '/(\S+)_(devel|preprod|prod)@sub.example.com$/': '$(1)@$(2).sub.example.com'

postfix/files/main.cf

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
{%- from "postfix/map.jinja" import postfix with context -%}
22
{%- set config = salt['pillar.get']('postfix:config', {}) -%}
33

4-
{%- if not salt['pillar.get']('postfix:mapping', False) %}
5-
{#- Let the user configure mapping manually. -#}
6-
{%- set processed_parameters = [] %}
7-
{%- else -%}
8-
{#- TODO: alias_maps probably belongs here, too: #}
9-
{%- set processed_parameters = [
10-
'virtual_alias_maps',
11-
'smtp_sasl_password_maps',
12-
'sender_canonical_maps',
13-
] %}
14-
{%- endif -%}
4+
{#- " | list": Python3.6 retuns dict_keys here, which needs to be converted into a list here. -#}
5+
{%- set processed_parameters = salt['pillar.get']('postfix:mapping', {}).keys() | list %}
156

167
{%- macro set_parameter(parameter, default=None) -%}
178
{% set value = config.get(parameter, default) %}

postfix/files/mapping.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
{%- else %}
2222
{#- Some settings need order, handle OrderedDict #}
2323
{% for item in data %}
24-
{{ format_value(item.keys()[0], item.values()[0]) }}
24+
{%- set key, value = item.popitem() %}
25+
{{ format_value(key, value) }}
2526
{%- endfor -%}
2627
{%- endif %}

0 commit comments

Comments
 (0)