202 lines
5.0 KiB
YAML
202 lines
5.0 KiB
YAML
- name: install Mailman 3 prerequisites
|
|
apt:
|
|
name:
|
|
- 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", "logrotate" ]
|
|
- 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: install pip packages
|
|
become_user: list
|
|
pip:
|
|
virtualenv: /opt/mailman3
|
|
virtualenv_python: python3
|
|
virtualenv_site_packages: yes
|
|
name: "{{ item }}"
|
|
loop:
|
|
- mysqlclient
|
|
- pylibmc
|
|
- git+https://github.com/notanumber/xapian-haystack.git
|
|
- mailman
|
|
- mailman-web
|
|
- mailman-hyperkitty
|
|
- name: find the site packages directory in the virtualenv
|
|
find:
|
|
paths: /opt/mailman3/lib
|
|
patterns: "python3*"
|
|
file_type: directory
|
|
register: find_ret
|
|
# This is necessary because python3-xapian was installed globally
|
|
- name: make sure that global site packages are inherited
|
|
file:
|
|
name: "{{ item.path }}/no-global-site-packages.txt"
|
|
state: absent
|
|
loop: "{{ find_ret.files }}"
|
|
- name: create mailman3 folder
|
|
file:
|
|
path: /etc/mailman3
|
|
state: directory
|
|
mode: 0755
|
|
- name: create mailman3 log folder
|
|
file:
|
|
path: /var/log/mailman3
|
|
state: directory
|
|
owner: list
|
|
group: list
|
|
- name: create mailman3-web log folder
|
|
file:
|
|
path: /var/log/mailman3/web
|
|
state: directory
|
|
owner: www-data
|
|
group: www-data
|
|
- name: create mailman-web.log
|
|
file:
|
|
path: /var/log/mailman3/web/mailman-web.log
|
|
state: touch
|
|
owner: www-data
|
|
group: www-data
|
|
- name: add Mailman 3 configs
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
group: "{{ item.group }}"
|
|
mode: 0640
|
|
loop:
|
|
- src: mailman3/templates/mailman.cfg.j2
|
|
dest: /etc/mailman3/mailman.cfg
|
|
group: list
|
|
- src: mailman3/templates/mailman-hyperkitty.cfg.j2
|
|
dest: /etc/mailman3/mailman-hyperkitty.cfg
|
|
group: list
|
|
- src: mailman3/templates/settings.py.j2
|
|
dest: /etc/mailman3/settings.py
|
|
group: www-data
|
|
- src: mailman3/templates/urls.py
|
|
dest: /etc/mailman3/urls.py
|
|
group: www-data
|
|
- src: mailman3/templates/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: mailman3/templates/{{ item }}.service
|
|
dest: "/etc/systemd/system/{{ item }}.service"
|
|
loop:
|
|
- mailman3
|
|
- mailman3-web
|
|
register: service_files
|
|
notify:
|
|
- reload systemd
|
|
- meta: flush_handlers
|
|
- name: stop and mask Mailman 2
|
|
systemd:
|
|
name: mailman
|
|
state: stopped
|
|
masked: yes
|
|
- 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: mailman3/templates/mailman.conf.j2
|
|
dest: /etc/apache2/sites-available/mailman.conf
|
|
notify: reload Apache
|
|
- 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: 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 cron jobs
|
|
replace:
|
|
path: /etc/cron.d/mailman
|
|
regexp: "^([*\\d@].*)$"
|
|
replace: "### \\1"
|
|
- name: check if mailman3-web setup was already done
|
|
slurp:
|
|
src: /opt/mailman3/web/setup-done
|
|
register: setup_done
|
|
ignore_errors: yes
|
|
- name: run one-time mailman3-web setup
|
|
become_user: www-data
|
|
shell:
|
|
executable: /bin/bash
|
|
chdir: /opt/mailman3
|
|
cmd: |
|
|
set -e
|
|
source bin/activate
|
|
mailman-web migrate
|
|
mailman-web collectstatic --no-input
|
|
mailman-web compress
|
|
echo -n 1 > web/setup-done
|
|
when: "'content' not in setup_done or (setup_done.content | b64decode) != '1'"
|
|
notify:
|
|
- restart mailman3-web
|
|
- name: enable and start new services
|
|
systemd:
|
|
name: "{{ item }}"
|
|
enabled: true
|
|
state: started
|
|
loop:
|
|
- mailman3
|
|
- mailman3-web
|
|
- name: add cron jobs
|
|
copy:
|
|
src: mailman3/templates/{{ item }}.cron
|
|
dest: "/etc/cron.d/{{ item }}"
|
|
loop:
|
|
- mailman3
|
|
- mailman3-web
|
|
- meta: flush_handlers
|
|
- name: create csc-general list
|
|
become_user: list
|
|
shell:
|
|
cmd: /opt/mailman3/bin/mailman create csc-general@{{ base_domain }} || true
|