From 87ce53d1d307a2560f1d874cdc17e31722408d3a Mon Sep 17 00:00:00 2001 From: Luciano Giacchetta Date: Tue, 10 Feb 2026 17:24:59 -0300 Subject: [PATCH] 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. --- .ansible/.lock | 0 README.md | 16 ++++++++++++ defaults/main.yml | 26 ++++++++++++++++++- handlers/main.yml | 5 ++++ tasks/main.yml | 39 +++++++++++++++++++++++++++- templates/10-auth.conf.j2 | 7 +++++ templates/10-mail.conf.j2 | 7 +++++ templates/10-master.conf.j2 | 51 +++++++++++++++++++++++++++++++++++++ templates/10-ssl.conf.j2 | 6 +++++ templates/dovecot.conf.j2 | 7 +++++ templates/main.cf.j2 | 18 +++++++++++++ tests/test.yml | 2 +- 12 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 .ansible/.lock create mode 100644 templates/10-auth.conf.j2 create mode 100644 templates/10-mail.conf.j2 create mode 100644 templates/10-master.conf.j2 create mode 100644 templates/10-ssl.conf.j2 create mode 100644 templates/dovecot.conf.j2 diff --git a/.ansible/.lock b/.ansible/.lock new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index eaf998e..c65da5b 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,22 @@ The role's behavior can be customized using the following variables. The default | postfix_inet_interfaces | all | The network interfaces Postfix listens on. Set to loopback-only to only accept mail from the server itself. | | postfix_inet_protocols | all | The IP protocols to use (ipv4, ipv6, or all). | +### **Dovecot Configuration** + +The role now supports installing and configuring Dovecot for IMAP/POP3 services. + +| Variable | Default Value | Description | +| :---- | :---- | :---- | +| dovecot_enabled | true | Whether to install and configure Dovecot. | +| dovecot_protocols | "imap pop3 lmtp" | Protocols to enable. | +| dovecot_mail_location | "maildir:~/Maildir" | Mail storage location. | +| dovecot_ssl | "yes" | SSL/TLS configuration (yes, no, required). | +| dovecot_ssl_cert | snakeoil | Path to SSL certificate. | +| dovecot_ssl_key | snakeoil | Path to SSL key. | +| dovecot_auth_mechanisms | "plain login" | Authentication mechanisms. | +| dovecot_postfix_sasl_enable | true | Enable Postfix SASL authentication via Dovecot. | +| dovecot_postfix_lmtp_enable | true | Enable Postfix delivery via Dovecot LMTP. | + ### **SASL Authentication** SASL authentication for the smarthost is **automatically enabled** if both postfix_relayhost_user and postfix_relayhost_password are defined. If they are not defined, Postfix will attempt to send mail without authentication. diff --git a/defaults/main.yml b/defaults/main.yml index 4a95e62..b6ad1c6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -34,4 +34,28 @@ postfix_relayhost: "" # Optional credentials for the relayhost. If these are defined, # SASL authentication will be automatically configured. # postfix_relayhost_user: "apikey" -# postfix_relayhost_password: "YourVeryLongAndComplexApiKey" \ No newline at end of file +# postfix_relayhost_password: "YourVeryLongAndComplexApiKey" + +# --- Dovecot Configuration --- + +# Whether to install and configure Dovecot +dovecot_enabled: true + +# Protocols to enable (imap, pop3, lmtp) +dovecot_protocols: "imap pop3 lmtp" + +# Mail storage location. Using Maildir in the user's home directory. +dovecot_mail_location: "maildir:~/Maildir" + +# SSL/TLS configuration +# Use 'yes', 'no' or 'required'. 'required' is recommended for production. +dovecot_ssl: "yes" +dovecot_ssl_cert: "