ansible-role-mailman/tasks/postorius-hyperkitty.yml

135 lines
5.9 KiB
YAML

---
- name: Create the postorius 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
when: ansible_distribution_file_variety == "RedHat"
- name: Create the postorius log directory
file: dest={{ item }} state=directory owner={{ mailman_user }} group={{ mailman_user }}
with_items:
- '{{ mailman_postorius_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 postorius setting files
become: True
become_user: '{{ mailman_user }}'
template: src=postorius_{{ item.name }}.j2 dest={{ mailman_postorius_dir }}/{{ item.name }} mode={{ item.perms }}
with_items: '{{ mailman_postorius_settings_files }}'
register: postorius_conf
- name: Setup postorius and hyperkitty
become_user: '{{ mailman_user }}'
shell: cd '{{ mailman_postorius_dir }}' && mkdir -p locale && {{ mailman_home }}/{{ mailman_virtualenv_name }}/bin/python3 manage.py migrate && {{ mailman_home }}/{{ mailman_virtualenv_name }}/bin/python3 manage.py compilemessages && {{ mailman_home }}/{{ mailman_virtualenv_name }}/bin/python3 manage.py collectstatic
args:
creates: '{{ mailman_postorius_dir }}/static/admin/js/actions.js'
- 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', 'postorius', 'hyperkitty', 'mailman_conf' ]
- name: Manage the postorius and hyperkitty services
block:
- name: Create the postorius service rundir
file: dest={{ mailman_postorius_uwsgi_rundir }} state=directory owner={{ mailman_user }} group={{ mailman_user }} mode='0755'
- name: Create the tmpfile entry for the postorius run
template: src=rundir_mailmansuite.conf.j2 dest=/usr/lib/tmpfiles.d/mailmansuite.conf owner=root group=root mode=0644
- name: Install the UWSGI configuration
template: src=postorius_uwsgi.ini.j2 dest={{ mailman_postorius_uwsgi_config_file }} mode='0640'
notify: Restart mailmansuite
- name: Install the mailmansuite uwsgi startup unit
template: src=mailmansuite-uwsgi.service.systemd.j2 dest=/lib/systemd/system/mailmansuite-uwsgi.service owner=root group=root mode=0644
register: mailmansuite_unit_install
- name: Reload the systemd configuration
systemd: daemon_reload=yes
when: mailmansuite_unit_install is changed
- name: Ensure that the UWSGI postorius service is started and enabled
service: name={{ mailman_postorius_uwsgi_servicename }} state=started enabled=yes
- name: Restart the UWSGI service if needed
service: name={{ mailman_postorius_uwsgi_servicename }} state=restarted
when: postorius_conf is defined and postorius_conf is changed
tags: [ 'mailman', 'postorius', 'hyperkitty', 'mailman_conf', 'hyperkitty_async', 'mailmansuite_uwsgi' ]
- name: Manage the hyperkitty async jobs
block:
- name: Install the hyperkitty qcluster startup unit
template: src=hyperkitty-qcluster.service.systemd.j2 dest=/lib/systemd/system/hyperkitty-qcluster.service owner=root group=root mode=0644
register: hyperkitty_unit_install
- name: Reload the systemd configuration
systemd: daemon_reload=yes
when: hyperkitty_unit_install is changed
- name: Ensure that the hyperkitty async jobs service is running and enabled
service: name=hyperkitty-qcluster state=started enabled=yes
when: mailman_hyperkitty_qcluster_standalone_service
tags: [ 'mailman', 'postorius', 'hyperkitty', 'mailman_conf', 'hyperkitty_async' ]
- name: Manage the hyperkitty async jobs
block:
- name: Ensure that the hyperkitty async jobs service is stopped and disabled
service: name=hyperkitty-qcluster state=stopped enabled=no
when: not mailman_hyperkitty_qcluster_standalone_service
tags: [ 'mailman', 'postorius', 'hyperkitty', 'mailman_conf', 'hyperkitty_async' ]
- name: Setup the postorius cron jobs
block:
- name: add a cron job that syncs the mailman core and postorius settings
cron:
job: "{{ mailman_postorius_dir }}/manage.py runjobs {{ item }} > {{ mailman_postorius_log_dir }}/runjobs-{{ item }}.log 2>&1"
special_time: '{{ item }}'
user: '{{ mailman_user }}'
name: "postorius / hyperkitty runjobs {{ item }}"
cron_file: 'postorius-runjobs-{{ item }}'
state: present
disabled: no
with_items: '{{ mailman_postorius_cronjob_frequency }}'
- name: postorius cron job that runs every 15 minutes
cron:
job: "{{ mailman_postorius_dir }}/manage.py runjobs quarter_hourly > {{ mailman_postorius_log_dir }}/runjobs-quarter_hourly.log 2>&1"
minute: "3,18,33,48"
user: '{{ mailman_user }}'
name: "postorius / hyperkitty runjobs quarter_hourly"
cron_file: 'postorius-runjobs-quarter_hourly'
disabled: no
state: present
- name: postorius cron job that runs every minute
cron:
job: "{{ mailman_postorius_dir }}/manage.py runjobs minutely > {{ mailman_postorius_log_dir }}/runjobs-minutely.log 2>&1"
minute: "*"
user: '{{ mailman_user }}'
name: "postorius / hyperkitty runjobs minutely"
cron_file: 'postorius-runjobs-minutely'
state: present
disabled: no
tags: [ 'mailman', 'postorius', 'hyperkitty', 'mailman_conf', 'postorius_cron' ]