diff options
author | Aaron LI <aly@aaronly.me> | 2018-03-07 18:15:08 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-03-14 11:35:08 +0800 |
commit | 1988a3dea8297735e8a333548815f28bff509107 (patch) | |
tree | 1fcaf0b2ca73d7caa0bac54e493ee4b66e9402c6 /roles/mail/templates/dovecot/userdb.j2 | |
parent | 6a7dba0f8d6790a0ad51656cc1a6d5f992c8d79b (diff) | |
download | ansible-dfly-vps-1988a3dea8297735e8a333548815f28bff509107.tar.bz2 |
mail/dovecot: use both passdb and userdb files to support user aliases
Diffstat (limited to 'roles/mail/templates/dovecot/userdb.j2')
-rw-r--r-- | roles/mail/templates/dovecot/userdb.j2 | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/roles/mail/templates/dovecot/userdb.j2 b/roles/mail/templates/dovecot/userdb.j2 new file mode 100644 index 0000000..c15df05 --- /dev/null +++ b/roles/mail/templates/dovecot/userdb.j2 @@ -0,0 +1,42 @@ +# +# /usr/local/etc/dovecot/userdb +# Dovecot user database in passwd-file format. +# +# References: +# * Dovecot - UserDatabase +# https://wiki.dovecot.org/UserDatabase +# * Dovecot - VirtualUsers +# https://wiki.dovecot.org/VirtualUsers +# * Dovecot - AuthDatabase / PasswdFile +# https://wiki.dovecot.org/AuthDatabase/PasswdFile +# +# +# Aaron LI +# + +# NOTE +# ---- +# We explicitly specify the *home* here, allowing that a user has the +# same mailboxes with all its alias(es). +# +# Fields +# ------ +# user:(password):uid:gid:(gecos):home:(shell):extra_fields +# * uid - override the global $mail_uid +# * gid - override the global $mail_gid +# * home - override the global $mail_home +# The ()-enclosed fields are ignored by Dovecot userdb lookup. +# ---------------------------------------------------------------------- +{% for user in mail.userdb %} +{% set name = user.name %} +{% set home = mail.vuser.home + "/" + name %} +# (user: {{ name }}) +{{ name }}:::::{{ home }}:: +{% if name != "root" and user.aliases is defined %} +# aliases +{% for alias in user.aliases|default([]) %} +{{ alias }}:::::{{ home }}:: +{% endfor %}{# alias #} +{% endif %}{# aliases #} +{% endfor %}{# user #} +# EOF |