- file: /etc/postfix/postfix-cert.cnf
# manage /etc/aliases if data found in pillar
-{% if 'aliases' in pillar.get('postfix', '') %}
+{% if 'aliases' in pillar.get('postfix', '') -%}
{{ postfix.aliases_file }}:
file.managed:
- source: salt://postfix/files/aliases
- cwd: /
- watch:
- file: {{ postfix.aliases_file }}
-{% endif %}
+{%- endif %}
+
+{%- macro postmap_file(filename, mode=644) %}
+{%- set file_path = '/etc/postfix/' ~ filename %}
+postmap_{{ filename }}:
+ file.managed:
+ - name: {{ file_path }}
+ - source: salt://postfix/files/{{ filename }}
+ - user: root
+ - group: root
+ - mode: {{ mode }}
+ - template: jinja
+ - require:
+ - pkg: postfix
+ cmd.wait:
+ - name: /usr/sbin/postmap {{ file_path }}
+ - cwd: /
+ - watch:
+ - file: {{ file_path }}
+{%- endmacro %}
+
+# manage /etc/postfix/virtual if data found in pillar
+{%- if 'virtual' in pillar.get('postfix', '') %}
+{{ postmap_file('virtual') }}
+{%- endif %}
+
+# manage /etc/postfix/smtp_auth if data found in pillar
+{%- if 'smtp_auth' in pillar.get('postfix', '') %}
+{{ postmap_file('smtp_auth', 600) }}
+{%- endif %}
+
+# manage /etc/postfix/sender_canonical if data found in pillar
+{%- if 'sender_canonical' in pillar.get('postfix', '') %}
+{{ postmap_file('sender_canonical') }}
+{%- endif %}
/etc/postfix/main.cf:
file.managed:
- cmd: postfix.pem
{% if 'aliases' in pillar.get('postfix', '') %}
- file: {{ postfix.aliases_file }}
+{% endif %}
+{% if 'virtual' in pillar.get('postfix', '') %}
+ - file: postmap_virtual
+{% endif %}
+{% if 'smtp_auth' in pillar.get('postfix', '') %}
+ - file: postmap_smtp_auth
+{% endif %}
+{% if 'sender_canonical' in pillar.get('postfix', '') %}
+ - file: postmap_sender_canonical
{% endif %}
- watch_in:
- service: postfix
--- /dev/null
+# Managed by config management
+# Don't change it manually
+#
+
+{% set canonical = salt['pillar.get']('postfix:smtp_auth',{}) -%}
+{% if canonical is iterable -%}
+{%- for entry in salt['pillar.get']('postfix:smtp_auth', []) -%}
+{%- for key,value in entry.iteritems() -%}
+{{ key }} {{ value }}
+{% endfor -%}
+{%- endfor -%}
+{% endif %}
+
+# vim: syntax=conf ts=8