Merge pull request #51 from EvaSDK/gh50-postconf-respect-file-type
Make postconf/newaliases respect file type
This commit is contained in:
commit
3183fc4351
@ -12,10 +12,24 @@ postfix:
|
|||||||
- watch:
|
- watch:
|
||||||
- pkg: postfix
|
- 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
|
# manage /etc/aliases if data found in pillar
|
||||||
{% if 'aliases' in pillar.get('postfix', '') %}
|
{% 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:
|
file.managed:
|
||||||
|
- name: {{ file_path }}
|
||||||
- source: salt://postfix/aliases
|
- source: salt://postfix/aliases
|
||||||
- user: root
|
- user: root
|
||||||
- group: root
|
- group: root
|
||||||
@ -23,13 +37,13 @@ postfix:
|
|||||||
- template: jinja
|
- template: jinja
|
||||||
- require:
|
- require:
|
||||||
- pkg: postfix
|
- pkg: postfix
|
||||||
|
{%- if need_newaliases %}
|
||||||
run-newaliases:
|
|
||||||
cmd.wait:
|
cmd.wait:
|
||||||
- name: newaliases
|
- name: newaliases
|
||||||
- cwd: /
|
- cwd: /
|
||||||
- watch:
|
- watch:
|
||||||
- file: {{ postfix.aliases_file }}
|
- file: {{ file_path }}
|
||||||
|
{%- endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# manage various mappings
|
# manage various mappings
|
||||||
@ -37,7 +51,11 @@ run-newaliases:
|
|||||||
{%- set need_postmap = False %}
|
{%- set need_postmap = False %}
|
||||||
{%- set file_path = salt['pillar.get']('postfix:config:' ~ mapping) %}
|
{%- set file_path = salt['pillar.get']('postfix:config:' ~ mapping) %}
|
||||||
{%- if ':' in file_path %}
|
{%- if ':' in file_path %}
|
||||||
{%- set file_path = file_path.split(':')[1] %}
|
{%- set file_type, file_path = file_path.split(':') %}
|
||||||
|
{%- else %}
|
||||||
|
{%- set file_type = default_database_type %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm") %}
|
||||||
{%- set need_postmap = True %}
|
{%- set need_postmap = True %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
postfix_{{ mapping }}:
|
postfix_{{ mapping }}:
|
||||||
|
Loading…
Reference in New Issue
Block a user