LukasGibb.mailgraph
Role Name
An Ansible role to install Mailgraph on Ubuntu servers.
Mailgraph is a simple tool that shows statistics of emails sent and received using Postfix and Sendmail. It creates daily, weekly, monthly, and yearly graphs of emails, including those that bounced or were rejected. Mailgraph was created by David Schweikert.
Requirements
This role also installs rrdtool, which Mailgraph needs to create the graphs.
A web server (like Apache) is needed to view Mailgraph at the following URL (depending on how your Apache is set up):
http://[hostname]:[port]/cgi-bin/mailgraph.cgi
For example: http://mail01:8080/cgi-bin/mailgraph.cgi
Role Variables
Postfix handles emails using filters like amavisd. After checking for spam and viruses, the emails go back to Postfix. If this variable is set to true, Mailgraph will not count your emails twice:
mailgraph_ignore_localhost
[default: true
]
Start the Mailgraph service when the server boots up:
mailgraph_start_on_boot
[default: true
]
Location of the mail log for Mailgraph to read:
mailgraph_mail_log
[default: /var/log/mail.log
]
Dependencies
This role needs a web server to host mailgraph.cgi. Jeff Geerling's geerlingguy.apache
role is used here. Make sure to enable the CGI module as shown below (i.e., apache_mods_enabled: cgi.load
).
Example Playbook
Simple setup without a domain:
URL: http://[hostname]:8080/cgi-bin/mailgraph.cgi
- hosts: mailservers
vars:
mailgraph_ignore_localhost: true
mailgraph_start_on_boot: true
mailgraph_mail_log: /var/log/mail.log
apache_listen_port: 8080
apache_mods_enabled: cgi.load
roles:
- geerlingguy.apache
- LukasGibb.mailgraph
More complex setup with a domain:
URL: http://example.com:8080/cgi-bin/mailgraph.cgi
- hosts: mailservers
vars:
mailgraph_ignore_localhost: true
mailgraph_start_on_boot: true
mailgraph_mail_log: /var/log/mail.log
apache_listen_port: 8080
apache_mods_enabled: cgi.load
apache_vhosts:
- servername: "example.com"
documentroot: "/var/www/example_com"
roles:
- geerlingguy.apache
- LukasGibb.mailgraph
License
MIT
Author Information
This role was created in 2018 by Lukas Gibb, from CloudJourneyman.com
An Ansible role that installs mailgraph on Ubuntu servers
ansible-galaxy install LukasGibb.mailgraph