From 6da70d21bbfbf613e6f0149c757c5e628ef227fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Mon, 24 Jan 2022 15:09:21 -0300 Subject: [PATCH] refactor(config): add `default_database_type` as default value --- postfix/config.sls | 3 +-- postfix/defaults.yaml | 1 + postfix/files/main.cf | 4 +--- postfix/init.sls | 5 +---- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/postfix/config.sls b/postfix/config.sls index 114ffd4..9121e9a 100644 --- a/postfix/config.sls +++ b/postfix/config.sls @@ -1,5 +1,4 @@ {% from "postfix/map.jinja" import postfix with context %} -{%- set default_database_type = postfix.get('config', {}).get('default_database_type', 'hash')%} include: - postfix @@ -119,7 +118,7 @@ postfix-config-file-managed-{{ domain }}-ssl-key: {%- elif ':' in file_path %} {%- set file_type, file_path = file_path.split(':') %} {%- else %} - {%- set file_type = default_database_type %} + {%- set file_type = postfix.default_database_type %} {%- endif %} {%- if not file_path.startswith('/') %} {%- set file_path = postfix.config_path ~ '/' ~ file_path %} diff --git a/postfix/defaults.yaml b/postfix/defaults.yaml index a0011b4..35017e0 100644 --- a/postfix/defaults.yaml +++ b/postfix/defaults.yaml @@ -13,3 +13,4 @@ postfix: service: postfix xbin_prefix: /usr dovecot_deliver: /usr/lib/dovecot/deliver + default_database_type: hash diff --git a/postfix/files/main.cf b/postfix/files/main.cf index 4abf47c..af33ada 100644 --- a/postfix/files/main.cf +++ b/postfix/files/main.cf @@ -118,8 +118,6 @@ policy-spf_time_limit = {{ policyd_spf.get('time_limit', '3600s') }} {{ set_parameter('smtpd_recipient_restrictions', recipient_restrictions) }} {# From init.sls #} -{%- set default_database_type = salt['pillar.get']('postfix:config:default_database_type', 'hash') %} - {%- for mapping, data in salt['pillar.get']('postfix:mapping', {}).items() %} {%- set file_path = salt['pillar.get']('postfix:config:' ~ mapping) %} {%- if file_path.startswith('proxy:') %} @@ -128,7 +126,7 @@ policy-spf_time_limit = {{ policyd_spf.get('time_limit', '3600s') }} {%- elif ':' in file_path %} {%- set file_type, file_path = file_path.split(':') %} {%- else %} - {%- set file_type = default_database_type %} + {%- set file_type = postfix.default_database_type %} {%- endif %} {%- if not file_path.startswith('/') %} {%- set file_path = postfix.config_path ~ '/' ~ file_path %} diff --git a/postfix/init.sls b/postfix/init.sls index 82bfcc2..7aebf5f 100644 --- a/postfix/init.sls +++ b/postfix/init.sls @@ -44,9 +44,6 @@ postfix-init-service-running-postfix-restart: - pkg: postfix-init-pkg-installed-postfix {%- endif %} -{# 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', '') %} {% if salt['pillar.get']('postfix:aliases:use_file', true) == true %} @@ -55,7 +52,7 @@ postfix-init-service-running-postfix-restart: {%- if ':' in file_path %} {%- set file_type, file_path = postfix.aliases_file.split(':') %} {%- else %} - {%- set file_type = default_database_type %} + {%- set file_type = postfix.default_database_type %} {%- endif %} {%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm") %} {%- set need_newaliases = True %}