syscom-dev-environment/mail/mailman2/mailman2.yml

65 lines
1.9 KiB
YAML

---
- hosts: mail
vars:
# use this password for all mailing lists
list_password: mailman
tasks:
- name: install packages for Mailman 2
apt:
name: "{{ item }}"
state: present
loop:
- mailman
- apache2
- name: override systemd services
import_role:
name: ../../roles/systemd_workarounds
vars:
services: [ "apache2" ]
- name: add Mailman config
template:
src: mm_cfg.py.j2
dest: /etc/mailman/mm_cfg.py
- name: create Mailman aliases file
command:
chdir: /var/lib/mailman
cmd: bin/genaliases
creates: /var/lib/mailman/data/aliases
- name: create initial list
shell:
chdir: /var/lib/mailman
cmd: "bin/newlist -a mailman root@{{ base_domain }} {{ list_password }} || true"
- name: restart Mailman
systemd:
name: mailman
state: restarted
- name: add Mailman aliases to Postfix config
lineinfile:
path: /etc/postfix/main.cf
regexp: "^alias_maps = .*$"
line: "alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases"
notify: reload Postfix
- name: add Apache config
template:
src: mailman.conf.j2
dest: /etc/apache2/sites-available/mailman.conf
notify: reload Apache
- name: enable Mailman site
command:
cmd: a2ensite mailman.conf
creates: /etc/apache2/sites-enabled/mailman.conf
notify: reload Apache
- name: disable default site
command:
cmd: a2dissite 000-default.conf
removes: /etc/apache2/sites-enabled/000-default.conf
notify: reload Apache
- name: enable CGI on Apache
command:
cmd: a2enmod cgid
creates: /etc/apache2/mods-enabled/cgid.load
notify: restart Apache
handlers:
- name: _imports
import_tasks: ../common.yml