ansible logo


If you need to build your own Postfix, Dovecot, SpamAssassin and Roundcube server for your own mail hosting, look no further than this all in one Ansible script. Just configure the global configuration file, run the script and BAM, you have a fully functioning mail server! This script completes an end to end configuration of the server and covers the following:

  1. Apache
  2. PHP 7.2
  3. MySQL
  4. Postfix
  5. Dovecot
  6. Letsencrypt
  7. Sieve
  8. SpamAssassin
  9. Postgrey
  10. iptables
  11. Roundcube Webmail with managesieve & two_factor plugins

Test Bed

  • Ansible control server running Ubuntu 18.04 LTS
  • Test server running Ubuntu 18.04 LTS


  1. Ansible control server
  2. SSH keys established between Ansible control server and destination server(s)
  3. 2x Public DNS A records pointing to the server to be set up

Role Dependancies

I use two Ansible Galaxy roles, one to setup iptables and one for Letsencrypt SSL certs (I was just too lazy to code that up all myself) You will need to run the following commands to download the Ansible Galaxy roles onto the Ansible control server:

ansible-galaxy install thefinn93.letsencrypt
ansible-galaxy install geerlingguy.firewall

Git Clone

I have all the yaml and conf scripts sitting in a public Github repository which can be cloned by running the following:

git clone


This will set up a complete mail server based on Digital Oceans how to and is expanded to include a few more services. I haven’t broken this script into roles yet and is in a “MVP” form for now. Questions and comments are always welcome as usual.

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.