From f1ef586370fda462cb2022f401b2fb7f7e88232e Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 6 Mar 2018 12:07:38 +0800 Subject: vars: add mail.userdb and use it in postfix virtual templates --- roles/mail/templates/postfix/virtual-users.j2 | 4 ++-- roles/mail/templates/postfix/virtual.j2 | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'roles/mail') diff --git a/roles/mail/templates/postfix/virtual-users.j2 b/roles/mail/templates/postfix/virtual-users.j2 index 4de0a60..2408196 100644 --- a/roles/mail/templates/postfix/virtual-users.j2 +++ b/roles/mail/templates/postfix/virtual-users.j2 @@ -41,6 +41,6 @@ # Envelope sender | Owner (SASL login names) # --------------------------------------------------------------------- {% set mydomain = mail.domains[0] %} -{% for user in ["aly", "wt", "lulu", "root"] %} -{{ user }}@{{ mydomain }} {{ user }}@{{ mydomain }} +{% for user in mail.userdb %} +{{ user.name }}@{{ mydomain }} {{ user.name }}@{{ mydomain }} {% endfor %} diff --git a/roles/mail/templates/postfix/virtual.j2 b/roles/mail/templates/postfix/virtual.j2 index 191d38d..ea72b05 100644 --- a/roles/mail/templates/postfix/virtual.j2 +++ b/roles/mail/templates/postfix/virtual.j2 @@ -29,17 +29,13 @@ # --------------------------------------------------------------------- {% set mydomain = mail.domains[0] %} {% for domain in mail.domains %} -{% for user in ["aly", "wt", "lulu"] %} -{{ user }}@{{ domain }} {{ user }}@{{ mydomain }} +# [domain: {{ domain }}] +{% for user in mail.userdb %} +# (user: {{ user.name }}) +{{ user.name }}@{{ domain }} {{ user.name }}@{{ mydomain }} +# aliases (if any) +{% for alias in user.aliases|default([]) %} +{{ alias }}@{{ domain }} {{ user.name }}@{{ mydomain }} {% endfor %} {% endfor %} -# -{% for domain in mail.domains %} -weitian@{{ domain }} wt@{{ mydomain }} -{% endfor %} -# -{% for domain in mail.domains %} -{% for user in ["postmaster", "hostmaster", "webmaster", "root", "abuse"] %} -{{ user }}@{{ domain }} root@{{ mydomain }} -{% endfor %} {% endfor %} -- cgit v1.2.2