2016-01-25 19:21:36 +01:00
|
|
|
---
|
2019-07-23 12:00:59 +02:00
|
|
|
|
2019-09-17 13:29:59 +02:00
|
|
|
- name: add rspamd apt key
|
2019-07-23 12:00:59 +02:00
|
|
|
apt_key: url="https://rspamd.com/apt-stable/gpg.key"
|
2019-07-15 19:00:23 +02:00
|
|
|
|
|
|
|
- name: add rspamd repository
|
2019-07-23 12:00:59 +02:00
|
|
|
apt_repository: repo="deb http://rspamd.com/apt-stable/ {{ ansible_distribution_release }} main"
|
2016-01-25 19:21:36 +01:00
|
|
|
|
|
|
|
- name: Install packages
|
2020-11-13 18:24:23 +01:00
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- bsd-mailx
|
|
|
|
- dovecot-core
|
|
|
|
- dovecot-imapd
|
|
|
|
- dovecot-lmtpd
|
|
|
|
- dovecot-ldap
|
|
|
|
- dovecot-managesieved
|
|
|
|
- dovecot-sieve
|
|
|
|
- fcgiwrap
|
|
|
|
- mailman
|
2020-02-29 19:09:37 +01:00
|
|
|
- mailman3-full
|
|
|
|
- postgresql
|
2020-11-13 18:24:23 +01:00
|
|
|
- postfix
|
|
|
|
- postsrsd
|
|
|
|
- redis-server
|
|
|
|
- redis-tools
|
|
|
|
- rspamd
|
2016-02-15 21:04:01 +01:00
|
|
|
|
|
|
|
- name: Create vmail group
|
|
|
|
group: name=vmail gid=500 state=present
|
|
|
|
|
|
|
|
- name: Create vmail user
|
2016-02-15 23:48:24 +01:00
|
|
|
user: name=vmail group=vmail uid=500 createhome=yes home=/var/vmail shell=/bin/false state=present
|
2016-02-15 21:04:01 +01:00
|
|
|
|
2016-02-15 23:48:24 +01:00
|
|
|
- name: Create dovecot ssl directory
|
|
|
|
file: path=/etc/dovecot/ssl state=directory mode=0750 owner=dovecot group=dovecot
|
|
|
|
|
|
|
|
- name: Create dovecot log directory
|
2016-02-23 14:56:18 +01:00
|
|
|
file: path=/var/log/dovecot state=directory mode=0750 owner=vmail group=vmail
|
2016-02-15 23:48:24 +01:00
|
|
|
|
2019-07-15 19:00:23 +02:00
|
|
|
- name: Create vmail sieve directory
|
2020-05-20 08:35:44 +02:00
|
|
|
file: path=/var/vmail/.sieve state=directory mode=0755 owner=vmail group=vmail
|
2019-07-15 19:00:23 +02:00
|
|
|
|
|
|
|
- name: Create vmail sieve-bin directory
|
2020-05-20 08:35:44 +02:00
|
|
|
file: path=/var/vmail/.sieve/bin state=directory mode=0755 owner=vmail group=vmail
|
2019-07-15 19:00:23 +02:00
|
|
|
|
2019-07-23 12:00:59 +02:00
|
|
|
- name: Configure redis
|
2019-07-15 19:00:23 +02:00
|
|
|
copy: src=redis.conf dest=/etc/redis/redis.conf
|
|
|
|
notify: Restart redis
|
|
|
|
|
|
|
|
- name: Copy static rspamd config
|
|
|
|
copy: src={{ item }} dest=/etc/rspamd/local.d/
|
|
|
|
notify: Restart rspamd
|
|
|
|
with_fileglob: "rspamd/local.d/*"
|
|
|
|
|
|
|
|
- name: Render rspamd config templates
|
|
|
|
template: src=rspamd/local.d/{{ item }}.j2 dest=/etc/rspamd/local.d/{{ item }}
|
|
|
|
notify: Restart rspamd
|
2019-07-23 12:00:59 +02:00
|
|
|
with_items:
|
|
|
|
- options.inc
|
2019-07-24 10:11:38 +02:00
|
|
|
- settings.conf
|
2019-07-23 12:00:59 +02:00
|
|
|
- arc.conf
|
|
|
|
- dkim_signing.conf
|
2019-07-15 19:00:23 +02:00
|
|
|
|
|
|
|
- name: Copy spam learn/unlearn sieve and shell scripts
|
|
|
|
copy: src=dovecot/{{ item }} dest=/var/vmail/.sieve/{{ item }}
|
|
|
|
with_items:
|
|
|
|
- bin/learn-spam.sh
|
|
|
|
- bin/learn-ham.sh
|
|
|
|
- move-spam.sieve
|
|
|
|
- report-spam.sieve
|
|
|
|
- report-ham.sieve
|
|
|
|
|
2016-02-15 21:04:01 +01:00
|
|
|
- name: Configure dovecot
|
|
|
|
template: src={{ item }}.j2 dest=/etc/{{ item }}
|
|
|
|
with_items:
|
|
|
|
- dovecot/dovecot-ldap.conf.ext
|
2019-07-15 19:00:23 +02:00
|
|
|
- dovecot/dovecot-ldap.conf.lmtp
|
2016-02-15 21:04:01 +01:00
|
|
|
- dovecot/local.conf
|
|
|
|
notify: Restart dovecot
|
|
|
|
|
2019-07-15 19:00:23 +02:00
|
|
|
- name: Compile sieve scripts
|
|
|
|
shell: sievec /var/vmail/.sieve/{{ item|basename }}
|
|
|
|
with_items:
|
|
|
|
- move-spam.sieve
|
|
|
|
- report-spam.sieve
|
|
|
|
- report-ham.sieve
|
|
|
|
|
|
|
|
- name: Ensure learn scripts are executable
|
2020-05-20 08:35:44 +02:00
|
|
|
file: mode=0755 path=/var/vmail/.sieve/bin/{{ item }}
|
2019-07-15 19:00:23 +02:00
|
|
|
with_items:
|
|
|
|
- learn-spam.sh
|
|
|
|
- learn-ham.sh
|
|
|
|
|
2016-04-06 22:58:54 +02:00
|
|
|
- name: Ensure dovecot certificates are available
|
|
|
|
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/dovecot/ssl/{{ mail_server }}.key -out /etc/dovecot/ssl/{{ mail_server }}.crt -days 730 -subj "/CN={{ mail_server }}" creates=/etc/dovecot/ssl/{{ mail_server }}.crt
|
|
|
|
notify: Restart dovecot
|
|
|
|
|
|
|
|
- name: Ensure correct dovecot certificate permissions
|
2016-04-08 20:00:21 +02:00
|
|
|
file: path=/etc/dovecot/ssl/{{ mail_server }}.key owner=dovecot mode=0400
|
2016-04-06 22:58:54 +02:00
|
|
|
notify: Restart dovecot
|
|
|
|
|
2016-02-29 21:05:21 +01:00
|
|
|
- name: Configure mailman
|
|
|
|
template: src={{ item }}.j2 dest=/etc/{{ item }}
|
|
|
|
with_items:
|
|
|
|
- mailman/mm_cfg.py
|
2016-02-29 21:07:45 +01:00
|
|
|
notify: Restart postfix
|
2016-02-29 21:05:21 +01:00
|
|
|
|
2016-02-29 21:29:44 +01:00
|
|
|
- name: Configure mailman vhost
|
2016-02-29 21:55:12 +01:00
|
|
|
template: src=nginx/vhost.j2 dest=/etc/nginx/sites-available/mailman
|
2016-02-29 21:29:44 +01:00
|
|
|
notify: Restart nginx
|
|
|
|
|
|
|
|
- name: Enable mailman vhost
|
|
|
|
file: src=/etc/nginx/sites-available/mailman dest=/etc/nginx/sites-enabled/mailman state=link
|
|
|
|
notify: Restart nginx
|
|
|
|
|
2016-04-06 22:58:54 +02:00
|
|
|
- name: Ensure mailman certificates are available
|
|
|
|
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/{{ mailman_domain }}.key -out /etc/nginx/ssl/{{ mailman_domain }}.crt -days 730 -subj "/CN={{ mailman_domain }}" creates=/etc/nginx/ssl/{{ mailman_domain }}.crt
|
|
|
|
notify: Restart nginx
|
|
|
|
|
|
|
|
- name: Ensure correct mailman certificate permissions
|
|
|
|
file: path=/etc/nginx/ssl/{{ mailman_domain }}.key owner=root mode=0400
|
|
|
|
notify: Restart nginx
|
|
|
|
|
2016-02-15 23:48:24 +01:00
|
|
|
- name: Create postfix ssl directory
|
|
|
|
file: path=/etc/postfix/ssl state=directory mode=0750 owner=postfix group=postfix
|
|
|
|
|
2016-01-25 19:21:36 +01:00
|
|
|
- name: Configure postfix
|
2016-02-22 18:07:24 +01:00
|
|
|
template: src={{ item }}.j2 dest=/etc/{{ item }}
|
|
|
|
with_items:
|
|
|
|
- postfix/main.cf
|
|
|
|
- postfix/master.cf
|
|
|
|
notify: Restart postfix
|
|
|
|
|
2019-07-23 15:53:52 +02:00
|
|
|
- name: Configure postsrsd
|
|
|
|
template: src={{ item }}.j2 dest=/etc/{{ item }}
|
|
|
|
with_items:
|
|
|
|
- default/postsrsd
|
|
|
|
- postsrsd.secret
|
|
|
|
notify: Restart postsrsd
|
|
|
|
|
2016-02-22 18:07:24 +01:00
|
|
|
- name: Configure postfix maps
|
2016-02-15 21:04:01 +01:00
|
|
|
template: src={{ item }}.j2 dest=/etc/{{ item }}
|
2016-02-01 20:52:34 +01:00
|
|
|
with_items:
|
2016-02-15 21:04:01 +01:00
|
|
|
- postfix/helo_access
|
2016-02-29 20:50:14 +01:00
|
|
|
- postfix/transport
|
2016-02-22 18:07:24 +01:00
|
|
|
- postfix/virtual-alias
|
|
|
|
notify: Run postmap
|
2016-01-25 19:21:36 +01:00
|
|
|
|
2018-09-20 18:30:42 +02:00
|
|
|
- name: Ensure postfix chroot has an up2date ca-certificates.crt file
|
|
|
|
copy: remote_src=yes src=/etc/ssl/certs/ca-certificates.crt dest=/var/spool/postfix/etc/ssl/certs/ca-certificates.crt
|
2016-04-06 22:40:38 +02:00
|
|
|
|
2016-04-01 08:10:00 +02:00
|
|
|
- name: Ensure postfix certificates are available
|
|
|
|
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/postfix/ssl/{{ mail_server }}.key -out /etc/postfix/ssl/{{ mail_server }}.crt -days 730 -subj "/CN={{ mail_server }}" creates=/etc/postfix/ssl/{{ mail_server }}.crt
|
|
|
|
notify: Restart postfix
|
|
|
|
|
|
|
|
- name: Ensure correct postfix certificate permissions
|
2016-04-08 20:00:21 +02:00
|
|
|
file: path=/etc/postfix/ssl/{{ mail_server }}.key owner=postfix mode=0400
|
2016-04-01 08:10:00 +02:00
|
|
|
notify: Restart postfix
|
|
|
|
|
2016-04-06 22:58:54 +02:00
|
|
|
- name: Configure certificate manager
|
2019-05-20 19:49:08 +02:00
|
|
|
template: src=certs.j2 dest=/etc/acertmgr/{{ mail_server }}_mail.conf
|
2019-02-23 23:54:24 +01:00
|
|
|
notify: Run acertmgr
|
2016-04-06 22:58:54 +02:00
|
|
|
|
|
|
|
- name: Configure certificate manager for mailman
|
2019-05-20 19:49:08 +02:00
|
|
|
template: src=mailman/certs.j2 dest=/etc/acertmgr/{{ mailman_domain }}_mailman.conf
|
2019-02-23 23:54:24 +01:00
|
|
|
notify: Run acertmgr
|
2016-02-15 21:04:01 +01:00
|
|
|
|
2016-01-25 19:21:36 +01:00
|
|
|
- name: Start dovecot
|
|
|
|
service: name=dovecot state=started enabled=yes
|
|
|
|
|
2016-02-29 21:29:44 +01:00
|
|
|
- name: Start fcgiwrap
|
|
|
|
service: name=fcgiwrap state=started enabled=yes
|
|
|
|
|
2016-01-25 19:21:36 +01:00
|
|
|
- name: Start postfix
|
|
|
|
service: name=postfix state=started enabled=yes
|
2016-02-01 20:52:34 +01:00
|
|
|
|
2019-07-23 15:53:52 +02:00
|
|
|
- name: Start postsrsd
|
|
|
|
service: name=postfix state=started enabled=yes
|
|
|
|
|
2019-07-15 19:00:23 +02:00
|
|
|
- name: Start redis
|
2019-07-23 17:23:14 +02:00
|
|
|
service: name=redis-server state=started enabled=yes
|
2019-07-15 19:00:23 +02:00
|
|
|
|
|
|
|
- name: Start rspamd
|
|
|
|
service: name=rspamd state=started enabled=yes
|