Hi all,
I've been setting up mail servers on FreeBSD and OpenBSD for a while and got tired of repeating the same steps every time, so I wrote a set of Ansible playbooks to automate the whole thing.
mail-bsd deploys a complete mail stack from scratch with a single command:
- OpenSMTPD — MTA (ports 25, 465, 587)
- Dovecot 2.3 — IMAP + Sieve filtering
- Rspamd — spam filtering and DKIM signing
What the playbook does:
- Installs and configures all packages from Jinja2 templates
- Generates a 2048-bit RSA DKIM key pair
- Generates 4096-bit Diffie-Hellman parameters for Dovecot
- Sets up standard mailbox folders with auto-expunge on Junk (30 days)
- Uses bsdauth on OpenBSD and PAM on FreeBSD
Prerequisites are minimal: SSH access as root, and a TLS certificate already in place. Everything else is handled by the playbook.
The repo also includes the full DNS records table (A, MX, SPF, DKIM) and instructions to extract the DKIM public key for the TXT record, which is always the fiddly part.
A note on Dovecot: the playbooks target 2.3, which is the version currently in both ports trees. They will be updated once 2.4 lands.
github.com
Feedback welcome — especially from anyone running this on less common setups.
I've been setting up mail servers on FreeBSD and OpenBSD for a while and got tired of repeating the same steps every time, so I wrote a set of Ansible playbooks to automate the whole thing.
mail-bsd deploys a complete mail stack from scratch with a single command:
- OpenSMTPD — MTA (ports 25, 465, 587)
- Dovecot 2.3 — IMAP + Sieve filtering
- Rspamd — spam filtering and DKIM signing
What the playbook does:
- Installs and configures all packages from Jinja2 templates
- Generates a 2048-bit RSA DKIM key pair
- Generates 4096-bit Diffie-Hellman parameters for Dovecot
- Sets up standard mailbox folders with auto-expunge on Junk (30 days)
- Uses bsdauth on OpenBSD and PAM on FreeBSD
Prerequisites are minimal: SSH access as root, and a TLS certificate already in place. Everything else is handled by the playbook.
The repo also includes the full DNS records table (A, MX, SPF, DKIM) and instructions to extract the DKIM public key for the TXT record, which is always the fiddly part.
A note on Dovecot: the playbooks target 2.3, which is the version currently in both ports trees. They will be updated once 2.4 lands.
GitHub - gnosisTux/ansible-playbooks: Personal collection of Ansible playbooks for self-hosted infrastructure.
Personal collection of Ansible playbooks for self-hosted infrastructure. - gnosisTux/ansible-playbooks
Feedback welcome — especially from anyone running this on less common setups.