From 7ce8798709625cb3470e8036b45182000641a7dd Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Thu, 29 Dec 2016 11:33:44 +0100 Subject: [PATCH 1/3] Run postmap on a specific set of file types According to postfix documentation [1], only some types of file require running postmap, others must be left alone. See github issue #50. [1] http://www.postfix.org/postmap.1.html --- postfix/init.sls | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/postfix/init.sls b/postfix/init.sls index 3f4e717..931dc03 100644 --- a/postfix/init.sls +++ b/postfix/init.sls @@ -37,8 +37,10 @@ run-newaliases: {%- set need_postmap = False %} {%- set file_path = salt['pillar.get']('postfix:config:' ~ mapping) %} {%- if ':' in file_path %} - {%- set file_path = file_path.split(':')[1] %} - {%- set need_postmap = True %} + {%- set file_type, file_path = file_path.split(':') %} + {%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm") %} + {%- set need_postmap = True %} + {%- endif %} {%- endif %} postfix_{{ mapping }}: file.managed: From b2fc0f1c0bb827fdfdb07f7fc3cfa6173f8c274c Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Thu, 29 Dec 2016 11:51:09 +0100 Subject: [PATCH 2/3] Add support for default_database_type configuration option See github issue #50. --- postfix/init.sls | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/postfix/init.sls b/postfix/init.sls index 931dc03..cd28d94 100644 --- a/postfix/init.sls +++ b/postfix/init.sls @@ -12,6 +12,9 @@ postfix: - watch: - pkg: postfix +{# Used for newaliases, postalias and postconf #} +{%- set default_database_type = salt['pillar.get']('postfix:config:default_database_type', 'hash') %} + # manage /etc/aliases if data found in pillar {% if 'aliases' in pillar.get('postfix', '') %} {{ postfix.aliases_file }}: @@ -38,9 +41,11 @@ run-newaliases: {%- set file_path = salt['pillar.get']('postfix:config:' ~ mapping) %} {%- if ':' in file_path %} {%- set file_type, file_path = file_path.split(':') %} - {%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm") %} - {%- set need_postmap = True %} - {%- endif %} + {%- else %} + {%- set file_type = default_database_type %} + {%- endif %} + {%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm") %} + {%- set need_postmap = True %} {%- endif %} postfix_{{ mapping }}: file.managed: From 961c1e10c4f7dfec7d577cd9a946c4e1d9d01c82 Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Thu, 29 Dec 2016 12:22:58 +0100 Subject: [PATCH 3/3] Allow alias_database file type to be respected for running newaliases See github issue #50. --- postfix/init.sls | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/postfix/init.sls b/postfix/init.sls index cd28d94..fc6d6c2 100644 --- a/postfix/init.sls +++ b/postfix/init.sls @@ -17,8 +17,19 @@ postfix: # manage /etc/aliases if data found in pillar {% if 'aliases' in pillar.get('postfix', '') %} -{{ postfix.aliases_file }}: + {%- set need_newaliases = False %} + {%- set file_path = postfix.aliases_file %} + {%- if ':' in file_path %} + {%- set file_type, file_path = postfix.aliases_file.split(':') %} + {%- else %} + {%- set file_type = default_database_type %} + {%- endif %} + {%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm") %} + {%- set need_newaliases = True %} + {%- endif %} +postfix_alias_database: file.managed: + - name: {{ file_path }} - source: salt://postfix/aliases - user: root - group: root @@ -26,13 +37,13 @@ postfix: - template: jinja - require: - pkg: postfix - -run-newaliases: + {%- if need_newaliases %} cmd.wait: - name: newaliases - cwd: / - watch: - - file: {{ postfix.aliases_file }} + - file: {{ file_path }} + {%- endif %} {% endif %} # manage various mappings