164 lines
6.0 KiB
YAML
164 lines
6.0 KiB
YAML
---
|
|
- name: Install the distribution dependencies
|
|
block:
|
|
- name: mailman distribution dependencies, RH/CentOS
|
|
yum: pkg={{ mailman_rh_dependencies }} state=present
|
|
|
|
- name: postorious distribution dependencies, RH/CentOS
|
|
yum: pkg={{ mailman_postorious_rh_dependencies }} state=present
|
|
|
|
when: ansible_distribution_file_variety == "RedHat"
|
|
tags: [ 'mailman' ]
|
|
|
|
- name: Create the mailman user
|
|
block:
|
|
- name: mailman user
|
|
user: name={{ mailman_srv_user }} createhome=no shell=/usr/sbin/nologin system=yes comment='Mailman User' generate_ssh_key=yes home={{ mailman_home }}
|
|
|
|
- name: Create the mailman user directory
|
|
file: dest={{ mailman_home }} state=directory mode=0755 owner={{ mailman_srv_user }} group={{ mailman_srv_user }}
|
|
|
|
when: ansible_distribution_file_variety == "RedHat"
|
|
tags: [ 'mailman' ]
|
|
|
|
- name: Create the mailman environment
|
|
block:
|
|
- name: Mailman directory tree
|
|
file: dest={{ item }} state=directory owner={{ mailman_user }} group={{ mailman_user }}
|
|
with_items:
|
|
- '{{ mailman_conf_dir }}'
|
|
- '{{ mailman_var_dir }}'
|
|
- '{{ mailman_log_dir }}'
|
|
- '{{ mailman_lock_dir }}'
|
|
- '{{ mailman_spool_dir }}'
|
|
|
|
- name: Create the mailman virtualenv. Manually, because python 3.6
|
|
become: True
|
|
become_user: '{{ mailman_user }}'
|
|
shell: cd '{{ mailman_home }}' && python3 -m venv '{{ mailman_virtualenv_name }}'
|
|
args:
|
|
creates: '{{ mailman_bindir }}/activate'
|
|
|
|
- name: Install the required packages in the mailman virtualenv
|
|
become: True
|
|
become_user: '{{ mailman_user }}'
|
|
pip:
|
|
executable: '{{ mailman_bindir }}/pip3'
|
|
virtualenv_command: '/bin/virtualenv-3'
|
|
virtualenv_site_packages: no
|
|
name: '{{ item.pkg }}'
|
|
extra_args: "{{ item.extra_args | default('') }}"
|
|
version: "{{ item.version | default('') }}"
|
|
editable: no # not required. Pass the editable flag.
|
|
with_items: '{{ mailman_pip_packages }}'
|
|
|
|
- name: Install the mailman and postfix configuration files
|
|
template: src={{ item }}.j2 dest={{ mailman_conf_dir }}/{{ item }} owner=root group={{ mailman_user }} mode=0440
|
|
with_items:
|
|
- 'mailman.cfg'
|
|
- 'postfix-mailman.cfg'
|
|
register: mailman_conf_install
|
|
|
|
- name: The mailman executables must be visible to systemd
|
|
file: src={{ mailman_bindir }}/{{ item }} dest=/sbin/{{ item }} state=link
|
|
with_items:
|
|
- 'mailman'
|
|
- 'master'
|
|
- 'runner'
|
|
- 'dkimsign'
|
|
- 'arcverify'
|
|
- 'arcsign'
|
|
- 'dknewkey'
|
|
- 'dkimverify'
|
|
- 'falcon-print-routes'
|
|
- 'falcon-bench'
|
|
- 'mako-render'
|
|
- 'alembic'
|
|
- 'mailman'
|
|
|
|
- name: Create the tmpfile entry for the mailman lock directory
|
|
template: src=tmpfile_mailman.conf.j2 dest=/usr/lib/tmpfiles.d/mailman.conf owner=root group=root mode=0644
|
|
|
|
- name: Install the mailman startup unit
|
|
template: src=mailman.service.systemd.j2 dest=/lib/systemd/system/mailman.service owner=root group=root mode=0644
|
|
register: mailman_unit_install
|
|
|
|
- name: Reload the systemd configuration
|
|
systemd: daemon_reload=yes
|
|
when: mailman_unit_install is changed
|
|
|
|
tags: [ 'mailman', 'mailman_conf' ]
|
|
|
|
- name: Create the postorious and hyperkitty environments
|
|
block:
|
|
- name: Set httpd_can_network_connect flag on and keep it persistent across reboots
|
|
seboolean:
|
|
name: httpd_can_network_connect
|
|
state: yes
|
|
persistent: yes
|
|
|
|
- name: Create the Postorious log directory
|
|
file: dest={{ item }} state=directory owner={{ mailman_user }} group={{ mailman_user }}
|
|
with_items:
|
|
- '{{ mailman_postorious_log_dir }}'
|
|
|
|
- name: Download the mailmansuite repository
|
|
become: True
|
|
become_user: '{{ mailman_user }}'
|
|
git:
|
|
dest: '{{ mailman_home }}/mailman-suite'
|
|
repo: '{{ mailman_repository }}'
|
|
force: yes
|
|
track_submodules: no
|
|
clone: yes
|
|
update: yes
|
|
recursive: yes
|
|
|
|
- name: Install the postorious setting files
|
|
become: True
|
|
become_user: '{{ mailman_user }}'
|
|
template: src=postorious_{{ item.name }}.j2 dest={{ mailman_postorious_dir }}/{{ item.name }} mode={{ item.perms }}
|
|
with_items: '{{ mailman_postorious_settings_files }}'
|
|
register: postorious_conf
|
|
|
|
- name: Install the UWSGI configuration
|
|
template: src=postorious_{{ item }}.j2 dest=/etc/{{ item }} mode=0640
|
|
with_items:
|
|
- 'uwsgi.ini'
|
|
|
|
- name: Setup postorius and hyperkitty
|
|
become_user: '{{ mailman_user }}'
|
|
shell: cd '{{ mailman_postorious_dir }}' && {{ mailman_home }}/{{ mailman_virtualenv_name }}/bin/python3 manage.py migrate && {{ mailman_home }}/{{ mailman_virtualenv_name }}/bin/python3 manage.py collectstatic
|
|
args:
|
|
creates: '{{ mailman_postorious_dir }}/static/admin/js/actions.js'
|
|
|
|
- name: Ensure that the UWSGI postorius service is started and enabled
|
|
service: name=uwsgi state=started enabled=yes
|
|
|
|
- name: Restart the UWSGI service if needed
|
|
service: name=uwsgi state=restarted
|
|
when: postorious_conf is changed
|
|
|
|
- name: Install the hyperkitty configuration file
|
|
template: src=mailman-hyperkitty.cfg.j2 dest={{ mailman_conf_dir }}/mailman-hyperkitty.cfg owner=root group={{ mailman_user }} mode=0440
|
|
when: mailman_use_hyperkitty_archiver | bool
|
|
register: mailman_hyperkitty_install
|
|
|
|
tags: [ 'mailman', 'postorious', 'hyperkitty', 'mailman_conf' ]
|
|
|
|
- name: Manage the mailman service
|
|
block:
|
|
- name: Ensure that the mailman service is started and enabled
|
|
service: name=mailman state=started enabled=yes
|
|
|
|
- name: Restart mailman if the configuration changed
|
|
service: name=mailman state=restarted
|
|
when: mailman_conf_install is changed
|
|
|
|
- name: Restart mailman if the configuration changed
|
|
service: name=mailman state=restarted
|
|
when: mailman_hyperkitty_install is changed
|
|
|
|
tags: [ 'mailman', 'postorious', 'hyperkitty', 'mailman_conf' ]
|
|
|