feat: add support for Dovecot IMAP/POP3 configuration

Introduces functionality to install and configure Dovecot alongside Postfix to provide IMAP/POP3 services.

Changes include:
- Added tasks to install Dovecot packages (core, imapd, pop3d, lmtpd).
- Added templates for main configuration and conf.d files (auth, master, ssl, mail).
- Defined default variables for protocols, SSL settings, and Maildir location.
- Enabled Postfix SASL and LMTP integration options.
- Added a handler to restart the Dovecot service.
- Updated README.md with the new configuration variables and usage instructions.
This commit is contained in:
2026-02-10 17:24:59 -03:00
parent 2861687888
commit 87ce53d1d3
12 changed files with 181 additions and 3 deletions

View File

@@ -0,0 +1,7 @@
# Dovecot authentication configuration
# Ansible managed: {{ ansible_managed }}
disable_plaintext_auth = {{ 'yes' if dovecot_ssl == 'required' else 'no' }}
auth_mechanisms = {{ dovecot_auth_mechanisms }}
!include auth-system.conf.ext

View File

@@ -0,0 +1,7 @@
# Dovecot mail location configuration
# Ansible managed: {{ ansible_managed }}
mail_location = {{ dovecot_mail_location }}
namespace inbox {
inbox = yes
}

View File

@@ -0,0 +1,51 @@
# Dovecot master configuration
# Ansible managed: {{ ansible_managed }}
service imap-login {
inet_listener imap {
port = 143
}
inet_listener imaps {
port = 993
ssl = yes
}
}
service pop3-login {
inet_listener pop3 {
port = 110
}
inet_listener pop3s {
port = 995
ssl = yes
}
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
mode = 0600
user = postfix
group = postfix
}
}
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
}
service auth-worker {
}
service dict {
unix_listener dict {
}
}

6
templates/10-ssl.conf.j2 Normal file
View File

@@ -0,0 +1,6 @@
# Dovecot SSL configuration
# Ansible managed: {{ ansible_managed }}
ssl = {{ dovecot_ssl }}
ssl_cert = {{ dovecot_ssl_cert }}
ssl_key = {{ dovecot_ssl_key }}

View File

@@ -0,0 +1,7 @@
# Dovecot configuration file
# Ansible managed: {{ ansible_managed }}
protocols = {{ dovecot_protocols }}
# Dictionary of configuration files
!include conf.d/*.conf

View File

@@ -48,3 +48,21 @@ smtp_tls_security_level = may
# Other settings
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
# Dovecot Integration
{% if dovecot_enabled | default(false) %}
# Use Maildir format
home_mailbox = Maildir/
{% if dovecot_postfix_sasl_enable | default(false) %}
# SASL Authentication via Dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
{% endif %}
{% if dovecot_postfix_lmtp_enable | default(false) %}
# Delivery via LMTP
mailbox_transport = lmtp:unix:private/dovecot-lmtp
{% endif %}
{% endif %}