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

174 lines
4.6 KiB
YAML

- hosts: coffee
tasks:
- name: setup the database on coffee
command:
cmd: mysql
stdin: |
CREATE DATABASE IF NOT EXISTS {{ item }};
CREATE USER IF NOT EXISTS {{ item }} IDENTIFIED BY '{{ item }}';
GRANT ALL PRIVILEGES ON {{ item }}.* TO {{ item }};
loop:
- mailman3
- mailman3web
- hosts: mail
tasks:
- name: install Mailman 3 prerequisites
apt:
name: "{{ item }}"
loop:
- python3-pip
- python3-dev
- python3-xapian
- virtualenv
- uwsgi
- uwsgi-plugin-python3
- default-libmysqlclient-dev
- sassc
- lynx
- git
- memcached
- name: override systemd services
import_role:
name: ../../roles/systemd_workarounds
vars:
services: [ "memcached" ]
- name: upgrade pip
pip:
executable: pip3
name: pip
extra_args: --upgrade
- name: create mailman3 directory
file:
path: /opt/mailman3
state: directory
owner: list
group: list
mode: '2755'
- name: create mailman3-web directory
file:
path: /opt/mailman3/web
state: directory
owner: www-data
group: www-data
- name: create mailman3-web run directory
file:
path: /run/mailman3-web
state: directory
owner: www-data
group: www-data
- name: install pip packages
become_user: list
pip:
virtualenv: /opt/mailman3
virtualenv_python: python3
name: "{{ item }}"
loop:
- mysqlclient
- pylibmc
- git+https://github.com/notanumber/xapian-haystack.git
- mailman
- mailman-web
- mailman-hyperkitty
- name: create mailman3 folder
file:
path: /etc/mailman3
state: directory
mode: 0755
- name: add Mailman 3 configs
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
group: "{{ item.group }}"
mode: 0640
loop:
- src: mailman.cfg.j2
dest: /etc/mailman3/mailman.cfg
group: list
- src: mailman-hyperkitty.cfg.j2
dest: /etc/mailman3/mailman-hyperkitty.cfg
group: list
- src: settings.py.j2
dest: /etc/mailman3/settings.py
group: www-data
- src: urls.py
dest: /etc/mailman3/urls.py
group: www-data
- src: uwsgi.ini
dest: /etc/mailman3/uwsgi.ini
group: www-data
- name: update cron log level
lineinfile:
path: /etc/default/cron
line: 'EXTRA_OPTS="-L 4"'
notify: restart cron
- name: add new services
copy:
src: "{{ item }}.service"
dest: "/etc/systemd/system/{{ item }}.service"
loop:
- mailman3
- mailman3-web
notify: reload systemd
- name: enable and start new services
systemd:
name: "{{ item }}"
enabled: true
state: started
loop:
- mailman3
- mailman3-web
- name: add cron jobs
copy:
src: "{{ item }}.cron"
dest: "/etc/cron.d/{{ item }}"
loop:
- mailman3
- mailman3-web
- name: enable mod_proxy_uwsgi
command:
cmd: a2enmod proxy_uwsgi
creates: /etc/apache2/mods-enabled/proxy_uwsgi.load
notify: restart Apache
- name: update Apache config
template:
src: mailman.conf.j2
dest: /etc/apache2/sites-available/mailman.conf
notify: reload Apache
- name: update Postfix config
blockinfile:
path: /etc/postfix/main.cf
block: |
owner_request_special = no
transport_maps = hash:/opt/mailman3/data/postfix_lmtp
local_recipient_maps =
proxy:unix:passwd.byname,
$alias_maps,
hash:/opt/mailman3/data/postfix_lmtp
notify: reload Postfix
- name: disable Mailman 2 in Postfix main.cf
lineinfile:
path: /etc/postfix/main.cf
regexp: "^alias_maps = .*$"
line: "alias_maps = hash:/etc/aliases"
notify: reload Postfix
- name: disable Mailman 2 in Postfix master.cf
copy:
src: master.cf
dest: /etc/postfix/master.cf
notify: reload Postfix
- name: disable Mailman 2 cron jobs
replace:
path: /etc/cron.d/mailman
regexp: "^([*\\d@].*)$"
replace: "### \\1"
handlers:
- name: _imports
import_tasks: ../common.yml
- name: reload systemd
systemd:
daemon_reload: true
- name: restart cron
systemd:
name: cron
state: restarted