diff --git a/playbooks/groups/mailman.yml b/playbooks/groups/mailman.yml index 88fb81acf4..a98106c2cf 100644 --- a/playbooks/groups/mailman.yml +++ b/playbooks/groups/mailman.yml @@ -100,6 +100,16 @@ mailman_hyperkitty_admin_db_pass: "{{ mailman_hk_admin_db_pass }}" mailman_hyperkitty_db_pass: "{{ mailman_hk_db_pass }}" mailman_hyperkitty_cookie_key: "{{ mailman_hk_cookie_key }}" + when: env != "staging" + - role: mailman3 + mailman_rest_api_user: "{{ mailman_stg_rest_api_user }}" + mailman_rest_api_pass: "{{ mailman_stg_rest_api_pass }}" + mailman_mailman_db_pass: "{{ mailman_mm_db_pass }}" + mailman_hyperkitty_admin_db_pass: "{{ mailman_hk_admin_db_pass }}" + mailman_hyperkitty_db_pass: "{{ mailman_hk_db_pass }}" + mailman_hyperkitty_cookie_key: "{{ mailman_hk_cookie_key }}" + mailman_hyperkitty_archiver_key: "{{ mailman_hk_stg_archiver_key }}" + when: env == "staging" - {role: fedmsg/base, when: env != "staging"} # Set up for fedora-messaging diff --git a/roles/mailman3/defaults/main.yml b/roles/mailman3/defaults/main.yml new file mode 100644 index 0000000000..64f5731c4f --- /dev/null +++ b/roles/mailman3/defaults/main.yml @@ -0,0 +1,36 @@ +--- +# Mailman core settings +mailman_webui_basedir: /srv/webui +mailman_webui_confdir: /etc/mailman3 +mailman_rest_api_user: restadmin +mailman_rest_api_pass: changeme +mailman_rest_api_workers: 2 +mailman_log_directory: /var/log/mailman3 +mailman_log_items: + - archiver + - bounce + - config + - database + - http + - runner + - smtp + - subscribe + - task + +# Mailman DB settings (the values should be provided by playbook) +mailman_db_server: localhost +mailman_mailman_db_pass: changeme + +# Hyperkitty/Postorius settings (the values should be provided by playbook) +mailman_hyperkitty_admin_db_pass: changeme +mailman_hyperkitty_db_pass: changeme +mailman_hyperkitty_cookie_key: changeme +mailman_hyperkitty_archiver_key: changeme +mailman_domains: +- lists.example.com +- lists.example.org +mailman_social_login: [] + +# Apache configuration +# Use mailman-web wsgi for mailman3 +wsgi_dir: /usr/lib/python3.9/site-packages/mailman_web diff --git a/roles/mailman3/files/favicon.ico b/roles/mailman3/files/favicon.ico new file mode 100644 index 0000000000..05567e1424 Binary files /dev/null and b/roles/mailman3/files/favicon.ico differ diff --git a/roles/mailman3/files/headers.html b/roles/mailman3/files/headers.html new file mode 100644 index 0000000000..fbea0abee4 --- /dev/null +++ b/roles/mailman3/files/headers.html @@ -0,0 +1,9 @@ + diff --git a/roles/mailman3/files/login_extra_top.html b/roles/mailman3/files/login_extra_top.html new file mode 100644 index 0000000000..e1713c0450 --- /dev/null +++ b/roles/mailman3/files/login_extra_top.html @@ -0,0 +1,6 @@ +
+By subscribing or posting to these mailing lists, you agree that any email +to the list is public and viewable worldwide (unless it's one of the few private mailing-lists). +For more details, see our +Privacy policy. +
diff --git a/roles/mailman3/files/logo-hyperkitty-fedora.png b/roles/mailman3/files/logo-hyperkitty-fedora.png new file mode 100644 index 0000000000..2806ade093 Binary files /dev/null and b/roles/mailman3/files/logo-hyperkitty-fedora.png differ diff --git a/roles/mailman3/files/mailman-hyperkitty.cfg b/roles/mailman3/files/mailman-hyperkitty.cfg new file mode 100644 index 0000000000..b442e216fa --- /dev/null +++ b/roles/mailman3/files/mailman-hyperkitty.cfg @@ -0,0 +1,20 @@ +# This is the mailman extension configuration file to enable HyperKitty as an +# archiver. Remember to add the following lines in the mailman.cfg file: +# +# [archiver.hyperkitty] +# class: mailman_hyperkitty.Archiver +# enable: yes +# configuration: /path/to/here/hyperkitty.cfg +# + +[general] + +# This is your HyperKitty installation, preferably on the localhost. This +# address will be used by Mailman to forward incoming emails to HyperKitty +# for archiving. It does not need to be publicly available, in fact it's +# better if it is not. +base_url: http://localhost/archives/ + +# Shared API key, must be the identical to the value in HyperKitty's +# settings. +api_key: {{ mailman_hypperkitty_archiver_key }} diff --git a/roles/mailman3/files/mailman-template-list-admin-action-post.txt b/roles/mailman3/files/mailman-template-list-admin-action-post.txt new file mode 100644 index 0000000000..1c7d64f788 --- /dev/null +++ b/roles/mailman3/files/mailman-template-list-admin-action-post.txt @@ -0,0 +1,15 @@ +As list administrator, your authorization is requested for the +following mailing list posting: + + List: $listname + From: $sender_email + Subject: $subject + +The message is being held because: + +$reasons + +At your convenience, visit your dashboard to approve or deny the +request: + +https://lists.fedoraproject.org/admin/lists/$list_id/held_messages diff --git a/roles/mailman3/files/mailman-template-list-member-generic-footer.txt b/roles/mailman3/files/mailman-template-list-member-generic-footer.txt new file mode 100644 index 0000000000..5ced9904aa --- /dev/null +++ b/roles/mailman3/files/mailman-template-list-member-generic-footer.txt @@ -0,0 +1,8 @@ +-- +_______________________________________________ +$display_name mailing list -- $listname +To unsubscribe send an email to ${short_listname}-leave@${domain} +Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ +List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines +List Archives: https://${domain}/archives/list/${listname} +Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue diff --git a/roles/mailman3/files/mailman-template-users-list-user-notice-hold.txt b/roles/mailman3/files/mailman-template-users-list-user-notice-hold.txt new file mode 100644 index 0000000000..eadc4a7216 --- /dev/null +++ b/roles/mailman3/files/mailman-template-users-list-user-notice-hold.txt @@ -0,0 +1,25 @@ +Your mail to '$listname' with the subject + + $subject + +Is being held until the list moderator can review it for approval. + +The message is being held because: + +$reasons + +Either the message will get posted to the list, or you will receive +notification of the moderator's decision. + +NOTE: If your message has been held due to size, please consider +this a rejection and a friendly request to reduce the size and +resend. The list moderators will not approve such messages. + +If you are attaching logs or command output, please trim it to a +minimal amount (we can ask for more context, if needed). + +If you are attaching an image, please crop it to reduce their size. + +Also keep in mind that attachments will be encoded by your mail +client (usually via base64) and this encoding increases the size by +as much as 33%. diff --git a/roles/mailman3/files/mailman3.logrotate.conf b/roles/mailman3/files/mailman3.logrotate.conf new file mode 100644 index 0000000000..cc5bb7438f --- /dev/null +++ b/roles/mailman3/files/mailman3.logrotate.conf @@ -0,0 +1,6 @@ +/var/log/mailman3/*.log { + missingok + notifempty + delaycompress + su root apache +} diff --git a/roles/mailman3/files/memcached.sysconfig b/roles/mailman3/files/memcached.sysconfig new file mode 100644 index 0000000000..4482f6e76c --- /dev/null +++ b/roles/mailman3/files/memcached.sysconfig @@ -0,0 +1,5 @@ +PORT="11211" +USER="memcached" +MAXCONN="1024" +CACHESIZE="655350" +OPTIONS="" diff --git a/roles/mailman3/files/navbar-brand.html b/roles/mailman3/files/navbar-brand.html new file mode 100644 index 0000000000..d44999aadd --- /dev/null +++ b/roles/mailman3/files/navbar-brand.html @@ -0,0 +1,5 @@ +{% load static %} + ++{% blocktrans %} +Account creation for the Fedora mailing-lists is done by +creating an account in FAS. +{% endblocktrans %} +
+ +{% url LOGIN_URL as login_url %} +{% blocktrans %}Already have an account? Then please sign in.{% endblocktrans %}
+ + +{% endblock %} diff --git a/roles/mailman3/files/top.html b/roles/mailman3/files/top.html new file mode 100644 index 0000000000..b607d331c3 --- /dev/null +++ b/roles/mailman3/files/top.html @@ -0,0 +1,10 @@ + + + + diff --git a/roles/mailman3/handlers/main.yml b/roles/mailman3/handlers/main.yml new file mode 100644 index 0000000000..685b5fc917 --- /dev/null +++ b/roles/mailman3/handlers/main.yml @@ -0,0 +1,12 @@ +--- +- name: restart mailman3 + service: name=mailman3 state=restarted + +- name: reload apache + service: name=httpd state=reloaded + +- name: restart memcached + service: name=memcached state=restarted + +- name: systemctl daemon-reload + command: /usr/bin/systemctl daemon-reload diff --git a/roles/mailman3/tasks/main.yml b/roles/mailman3/tasks/main.yml new file mode 100644 index 0000000000..e3c4ef1f6a --- /dev/null +++ b/roles/mailman3/tasks/main.yml @@ -0,0 +1,452 @@ +--- +# Configuration for Mailman 3 +# PostgreSQL initialization must have been done already + +# +# SELinux +# +- name: Set the SELinux policy for the fulltext index + community.general.sefcontext: + target: "{{ mailman_webui_basedir }}/fulltext_index(/.*)?" + setype: httpd_sys_rw_content_t + state: present + tags: + - mailman + - selinux + +- name: Set the SELinux policy for the static files directory + community.general.sefcontext: + target: "{{ mailman_webui_basedir }}/static(/.*)?" + setype: httpd_sys_content_t + state: present + tags: + - mailman + - selinux + +- name: Set the SELinux policy for the templates override directory + community.general.sefcontext: + target: "{{ mailman_webui_basedir }}/templates(/.*)?" + setype: httpd_sys_content_t + state: present + tags: + - mailman + - selinux + +- name: set the SELinux policy for the log directory + community.general.sefcontext: + target: "{{ mailman_log_directory }}(/.*)?" + setype: httpd_log_t + state: present + tags: + - mailman + - selinux + +- name: Set the SELinux policy for the generated postfix databases + community.general.sefcontext: + target: "{{ mailman_webui_basedir }}/var/data/postfix_.*" + setype: etc_aliases_t + state: present + tags: + - mailman + - selinux + +- name: Set the SELinux policy for the old static archives + community.general.sefcontext: + target: "{{ mailman_webui_basedir }}/old-archives/pipermail(/.*)?" + setype: httpd_sys_content_t + state: present + tags: + - mailman + - selinux + +- name: Allow Apache to remotely connect to PostgreSQL + ansible.posix.seboolean: + name: httpd_can_network_connect_db + state: yes + persistent: yes + tags: + - mailman + - selinux + +- name: Allow Apache to remotely connect to Mailman + ansible.posix.seboolean: + name: httpd_can_network_connect + state: yes + persistent: yes + tags: + - mailman + - selinux + +- name: Allow Apache to remotely connect to Memcached + ansible.posix.seboolean: + name: httpd_can_network_memcache + state: yes + persistent: yes + tags: + - mailman + - selinux + + +- name: Install needed packages + ansible.builtin.package: + name: {{item}} + state: present + with_items: + - httpd + - hyperkitty + - fedora-messaging + - mailman3 + - memcached + - postorius + - python3-mailman-hyperkitty + - python3-mailman-web + - python3-mod_wsgi + - python3-pylibmc + - python3-psycopg2 + - python3-whoosh + - sassc + tags: + - packages + - mailman + +- name: Set the mailman conffile + ansible.builtin.template: + src: mailman.cfg.j2 + dest: /etc/mailman.cfg + owner: mailman + group: mailman + mode: 0640 + tags: + - config + - mailman + notify: + - restart mailman3 + +# +# Logging +# +- name: Ensuring log directory exists + ansible.builtin.file: + path: "{{ mailman3_log_directory }}" + state: directory + owner: mailman + group: mailman + tags: + - logging + - mailman + +- name: Mailman logging -- rotation + ansible.builtin.copy: + src: mailman3.logrotate.conf + dest: /etc/logrotate.d/mailman3 + tags: + - logging + - mailman + +- name: Ensuring mailman-core is started + ansible.builtin.service: + name: mailman3 + state: started + enabled: yes + tags: + - mailman + +# +# HyperKitty + Postorius setup +# +- name: Create site/en dir + ansible.builtin.file: + state: directory + path: /var/lib/mailman3/templates/site/en + tags: + - config + - mailman + +- name: Set default list footer + ansible.builtin.copy: + src: mailman-template-list-member-generic-footer.txt + dest: /var/lib/mailman3/templates/site/en/list:member:generic:footer.txt + owner: mailman + group: mailman + mode: 0644 + tags: + - config + - mailman + +- name: Set default list:admin:action:post template + ansible.builtin.copy: + src: mailman-template-list-admin-action-post.txt + dest: /var/lib/mailman3/templates/site/en/list:admin:action:post.txt + owner: mailman + group: mailman + mode: 0644 + tags: + - config + - mailman + +- name: Create lists/users.lists.fedoraproject.org/en template dir + ansible.builtin.file: + state: directory + path: /var/lib/mailman3/templates/lists/users.lists.fedoraproject.org/en + tags: + - config + - mailman + +- name: Set list:user:notice:hold template for users list + anisble.builtin.copy: + src: mailman-template-users-list-user-notice-hold.txt + dest: /var/lib/mailman3/templates/lists/users.lists.fedoraproject.org/en/list:user:notice:hold.txt + owner: mailman + group: mailman + mode: 0644 + tags: + - config + - mailman + +- name: Install the hyperkitty/postorius settings file + ansible.builtin.template: + src: settings.py.j2 + dest: "{{ mailman_webui_confdir }}/settings.py" + owner: root + group: apache + mode: 0640 + tags: + - config + - mailman + notify: + - reload apache + +- name: Install the hyperkitty/postorius httpd conf file + ansible.builtin.template: + src: apache.conf.j2 + dest: /etc/httpd/conf.d/mailman-webui.conf + tags: + - config + - mailman + notify: + - reload apache + +- name: Create the fulltext index dir + ansible.builtin.file: + path: "{{ mailman_webui_basedir }}/fulltext_index" + state: directory + owner: apache + group: apache + mode: 0755 + tags: mailman + +- name: Create the hyperkitty static files dirs + ansible.builtin.file: + path: "{{ mailman_webui_basedir }}/{{ item }}" + state: directory + owner: root + group: root + mode: 0755 + with_items: + - static + - static-fedora + register: static_root_dir + tags: mailman + +- name: Create the fedora-specific hyperkitty img dir + ansible.builtin.file: + path: "{{ mailman_webui_basedir }}/static-fedora/hyperkitty/img" + state: directory + owner: root + group: root + mode: 0755 + tags: + - mailman + - hyperkitty + +- name: Create the hyperkitty templates override dirs + ansible.builtin.file: + path: "{{ mailman_webui_basedir }}/templates/{{ item }}" + state: directory + owner: root + group: root + mode: 0755 + with_items: + - hyperkitty + - django_mailman3 + tags: + - mailman + - hypperkitty + +# Add the Nest banner +# See issue https://pagure.io/fedora-infrastructure/issue/10103 +- name: Replace the top.html template in hyperkitty/postorius to change banner + ansible.builtin.copy: + src: top.html + dest: "{{ mailman_webui_basedir }}/templates/hyperkitty/top.html" + notify: + - reload apache + tags: + - mailman + - banner + - hyperkitty + +- name: Install our fedora-specific logo + ansible.builtin.copy: + src: logo-hyperkitty-fedora.png + dest: "{{ mailman_webui_basedir }}/static-fedora/logo-hyperkitty-fedora.png" + tags: + - mailman + - hyperkitty + +- name: Install our fedora-specific favicon + ansible.builtin.copy: + src: favicon.ico + dest: "{{ mailman_webui_basedir }}/static-fedora/favicon.ico" + tags: + - mailman + - hyperkitty + +- name: Install our fedora-specific robots.txt + ansible.builtin.copy: + src: robots.txt + dest: "{{ mailman_webui_basedir }}/static-fedora/robots.txt" + tags: + - mailman + - hyperkitty + +- name: Install our fedora-specific brand template override + ansible.builtin.copy: + src: navbar-brand.html + dest: "{{ mailman_webui_basedir }}/templates/hyperkitty/navbar-brand.html" + tags: + - mailman + - hyperkitty + +- name: Install our fedora-specific page headers + ansible.builtin.copy: + src: headers.html + dest: "{{ mailman_webui_basedir }}/templates/hyperkitty/headers.html" + tags: + - mailman + - hyperkitty + +- name: Install our fedora-specific login page extension + ansible.builtin.copy: + src: login_extra_top.html + dest: "{{ mailman_webui_basedir }}/templates/django_mailman3/login_extra_top.html" + tags: + - mailman + - hyperkitty + +- name: Create dirs for signup_closed page + ansible.builtin.file: + path: "{{ mailman_webui_basedir }}/templates/account" + state: directory + owner: root + group: root + mode: 0755 + tags: + - mailman + - hyperkitty + +- name: Install our fedora-specific signup_closed page + ansible.builtin.copy: + src: signup_closed.html + dest: "{{ mailman_webui_basedir }}/templates/account/signup_closed.html" + tags: + - mailman + - hyperkitty + +- name: Install our fedmenu js hook + ansible.builtin.template: + src: bottom.html + dest: "{{mailman_webui_basedir }}/templates/hyperkitty/bottom.html" + tags: + - mailman + - hyperkitty + + +- name: Ensuring we have correct DB schema for django apps + ansible.builtin.command: + cmd: mailman-web migrate + chdir: /etc/mailman3 + become_user: mailman + tags: + - mailman + - db + +# +# Plug HyperKitty into Mailman +# +- name: Copy the mailman-hyperkitty conffile + ansible.builtin.copy: + src: mailman-hyperkitty.cfg + dest: "/etc/mailman3.d/hyperkitty.cfg" + owner: mailman + group: mailman + mode: 0640 + tags: + - config + - mailman + - hyperkitty + notify: + - restart mailman3 + +- name: Populating static_root dir with django files/css + ansible.builtin.command: + cmd: mailman-web collectstatic --no-input + chdir: /etc/mailman3 + become_user: mailman + when: + - static_root_dir is changed + +# +# Scripts +# + +- name: Install the staging-sync script + ansible.builtin.copy: + src: prod-to-stg.py + dest: "{{ mailman_webui_basedir }}/bin/prod-to-stg.py" + when: env == "staging" + tags: mailman + +# +# Systemd +# +- name: Install the systemd service files + ansible.builtin.template: + src: "{{ item }}.service.j2" + dest: "/etc/systemd/system/{{ item }}.service" + with_items: + - webui-qcluster + - webui-warm-up-cache + notify: + - systemctl daemon-reload + tags: + - config + - mailman + - systemd + +# Memcached +- name: Set the memcached sysconfig file + ansible.builtin.copy: + src: memcached.sysconfig + dest: /etc/sysconfig/memcached + notify: + - restart memcached + tags: + - mailman + - memcached + +# Start services +- name: Start services + ansible.builtin.systemd: + state: started + enabled: yes + name: {{item}} + with_items: + - httpd + - mailman3 + - postfix + - webui-qcluster + - webui-warm-up-cache + tags: + - mailman + - hyperkitty diff --git a/roles/mailman3/templates/apache.conf.j2 b/roles/mailman3/templates/apache.conf.j2 new file mode 100644 index 0000000000..cdf09069bb --- /dev/null +++ b/roles/mailman3/templates/apache.conf.j2 @@ -0,0 +1,43 @@ +Alias /favicon.ico {{ mailman_webui_basedir }}/static/favicon.ico +Alias /robots.txt {{ mailman_webui_basedir }}/static/robots.txt +Alias /static {{ mailman_webui_basedir }}/static + +#ErrorLog /var/log/httpd/webui_error.log +#CustomLog /var/log/httpd/webui_access.log combined + +WSGIScriptAlias / {{ wsgi_dir }}/wsgi.py +WSGIDaemonProcess webui display-name=webui maximum-requests=1000 processes=4 threads=30 python-path={{ wsgi_dir }} +WSGIProcessGroup webui +WSGISocketPrefix run/wsgi +WSGIRestrictStdout On +WSGIRestrictSignal Off +WSGIPythonOptimize 1 + +