148 lines
5.4 KiB
YAML
148 lines
5.4 KiB
YAML
---
|
|
- name: Install the distribution dependencies
|
|
block:
|
|
- name: mailman distribution dependencies, RH/CentOS
|
|
yum: pkg={{ mailman_rh_dependencies }} state=present
|
|
|
|
- name: postorius distribution dependencies, RH/CentOS
|
|
yum: pkg={{ mailman_postorius_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
|
|
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'
|
|
|
|
- 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: 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
|
|
|
|
- name: Install the mailman and mailmansuite logrotate configurations
|
|
template: src={{ item }}-logrotate.j2 dest=/etc/logrotate.d/{{ item }} owner=root mode=0444
|
|
with_items:
|
|
- 'mailman'
|
|
- 'mailman-postorius'
|
|
|
|
tags: [ 'mailman', 'mailman_conf' ]
|
|
|
|
|
|
- name: Add the maintenance cron jobs
|
|
tags: ['mailman', 'mailman_conf', 'mailman_cron']
|
|
block:
|
|
- name: Add a daily cron job that sends digests
|
|
cron:
|
|
job: "{{ mailman_bindir }}/mailman -C {{ mailman_conf_dir }}/mailman.cfg digests --periodic > {{ mailman_log_dir }}/mailman_cron_digest.log 2>&1"
|
|
special_time: daily
|
|
user: '{{ mailman_user }}'
|
|
name: "Mailman digests"
|
|
cron_file: 'mailman-digests'
|
|
state: present
|
|
|
|
- name: Add a daily cron job that sends notifications to the list administrators and list owners
|
|
cron:
|
|
job: "{{ mailman_bindir }}/mailman -C {{ mailman_conf_dir }}/mailman.cfg notify > {{ mailman_log_dir }}/mailman_cron_notifications.log 2>&1"
|
|
minute: '0'
|
|
hour: '7'
|
|
user: '{{ mailman_user }}'
|
|
name: "Mailman notifications"
|
|
cron_file: 'mailman-notifications'
|
|
state: "{% if mailman_enable_daily_notifications %}present{% else %}absent{% endif %}"
|
|
|
|
- name: Install some default templates
|
|
block:
|
|
- name: Create the 'site' directory and the language subdirs
|
|
file: dest={{ mailman_var_dir }}/templates/site/{{ item }} state=directory owner={{ mailman_user }} group={{ mailman_user}}
|
|
with_items:
|
|
- it
|
|
- en
|
|
|
|
- name: Install the custom templates
|
|
template: src=site/{{ item }}.j2 dest={{ mailman_var_dir }}/templates/site/{{ item }} owner={{ mailman_user }} group={{ mailman_user}}
|
|
with_items: '{{ mailman_custom_templates }}'
|
|
|
|
tags: [ 'mailman', 'mailman_templates' ]
|