Merge pull request #56 from vquiering/add_mysql_query_to_virtual

Add a mysql query to 'virtual' files
This commit is contained in:
N 2018-03-08 09:43:26 +00:00 committed by GitHub
commit e9ef0aa547
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 3 deletions

View file

@ -110,6 +110,21 @@ postfix:
hosts: DB_HOST
dbname: postfix_db
# add mysql query to virtual
mysql:
virtual_mailbox_domains:
table: virtual_domains
select_field: 1
where_field: name
virtual_alias_maps:
table: virtual_aliases
select_field: destination
where_field: email
virtual_mailbox_maps:
table: virtual_users
select_field: 1
where_field: email
aliases:
# manage single aliases
# this uses the aliases file defined in the minion config, /etc/aliases by default

View file

@ -1,3 +1,10 @@
{%- if 'mysql' in salt['pillar.get']('postfix:config:virtual_alias_maps', '') %}
{%- set config = salt['pillar.get']('postfix:mysql:virtual_alias_maps', {}) -%}
{%- for key,value in salt['pillar.get']('postfix:vmail').items() %}
{{ key }} = {{ value }}
{%- endfor %}
query = SELECT {{ config.select_field|default('destination') }} FROM {{ config.table|default('virtual_aliases') }} WHERE {{ config.where_field|default('email') }}='%s'
{%- else %}
{% set config = salt['pillar.get']('postfix:vmail', {}) -%}
{% macro set_parameter(parameter, default=None) -%}
{% set value = config.get(parameter, default) -%}
@ -14,4 +21,4 @@
{{ set_parameter('table', 'alias') }}
{{ set_parameter('select_field', 'goto') }}
{{ set_parameter('where_field', 'address') }}
{%- endif %}

View file

@ -1,3 +1,10 @@
{%- if 'mysql' in salt['pillar.get']('postfix:config:virtual_mailbox_domains', '') %}
{%- set config = salt['pillar.get']('postfix:mysql:virtual_mailbox_domains', {}) -%}
{%- for key,value in salt['pillar.get']('postfix:vmail').items() %}
{{ key }} = {{ value }}
{%- endfor %}
query = SELECT {{ config.select_field|default('1') }} FROM {{ config.table|default('virtual_domains') }} WHERE {{ config.where_field|default('name') }}='%s'
{%- else %}
{% set config = salt['pillar.get']('postfix:vmail', {}) -%}
{% macro set_parameter(parameter, default=None) -%}
{% set value = config.get(parameter, default) -%}
@ -14,4 +21,4 @@
{{ set_parameter('table', 'domain') }}
{{ set_parameter('select_field', 'domain') }}
{{ set_parameter('where_field', 'domain') }}
{%- endif %}

View file

@ -1,3 +1,10 @@
{%- if 'mysql' in salt['pillar.get']('postfix:config:virtual_mailbox_maps', '') %}
{%- set config = salt['pillar.get']('postfix:mysql:virtual_mailbox_maps', {}) -%}
{%- for key,value in salt['pillar.get']('postfix:vmail').items() %}
{{ key }} = {{ value }}
{%- endfor %}
query = SELECT {{ config.select_field|default('1') }} FROM {{ config.table|default('virtual_users') }} WHERE {{ config.where_field|default('email') }}='%s'
{%- else %}
{% set config = salt['pillar.get']('postfix:vmail', {}) -%}
{% macro set_parameter(parameter, default=None) -%}
{% set value = config.get(parameter, default) -%}
@ -14,4 +21,4 @@
{{ set_parameter('table', 'mailbox') }}
{{ set_parameter('select_field', 'maildir') }}
{{ set_parameter('where_field', 'username') }}
{%- endif %}