From 665e92732e232039bd480307707aaee4e9778b92 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 13 Feb 2020 21:00:10 +0100 Subject: [PATCH] Cleanup of the postorious settings.py. Introduce the hyperkitty configuration. --- defaults/main.yml | 8 +++++++ tasks/main.yml | 28 ++++++++++++++++-------- templates/mailman-hyperkitty.cfg.j2 | 22 +++++++++++++++++++ templates/mailman.cfg.j2 | 6 ++++++ templates/postorious_settings.py.j2 | 33 ++++++++++++++--------------- 5 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 templates/mailman-hyperkitty.cfg.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 7f750e6..da8befa 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,7 +10,13 @@ mailman_lock_dir: '/var/lock/mailman' mailman_spool_dir: '/var/spool/mailman' mailman_layout: 'fhs' mailman_site_owner: 'mailman@example.com' +mailman_from_email: 'mailman@example.com' +mailman_server_email: 'mailman@example.com' mailman_noreply_addr: 'noreply' +mailman_use_social_account_providers: False +mailman_use_memcache: False +mailman_memcache_hosts: '127.0.0.1:11211' +mailman_site_url: 'http://localhost' mailman_admins: - "'Mailman Suite Admin', 'mailman@example.com'" @@ -105,3 +111,5 @@ mailman_postorious_db_user: mailmansuite_u # mailman_postorious_db_password: mailman_postorious_db_host: 'localhost' mailman_postorious_db_port: '' +mailman_use_hyperkitty_archiver: True + diff --git a/tasks/main.yml b/tasks/main.yml index 84f7fd9..b25366b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -43,7 +43,6 @@ become: True become_user: '{{ mailman_user }}' pip: - #virtualenv: '{{ mailman_virtualenv_name }}' executable: '{{ mailman_bindir }}/pip3' virtualenv_command: '/bin/virtualenv-3' virtualenv_site_packages: no @@ -88,13 +87,6 @@ systemd: daemon_reload=yes when: mailman_unit_install is changed - - 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 - tags: [ 'mailman', 'mailman_conf' ] - name: Create the postorious and hyperkitty environments @@ -147,5 +139,23 @@ service: name=uwsgi state=restarted when: postorious_conf is changed - tags: [ 'mailman', 'postorious', 'hyperkitty' ] + - 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 + +- 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' ] diff --git a/templates/mailman-hyperkitty.cfg.j2 b/templates/mailman-hyperkitty.cfg.j2 new file mode 100644 index 0000000..d44368f --- /dev/null +++ b/templates/mailman-hyperkitty.cfg.j2 @@ -0,0 +1,22 @@ +# 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/mailman-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. +# However, if your Mailman installation is accessed via HTTPS, the URL needs +# to match your SSL certificate (e.g. https://lists.example.com/hyperkitty). +base_url: {{ mailman_site_url }}/hyperkitty/ + +# Shared API key, must be the identical to the value in HyperKitty's +# settings. +api_key: {{ mailman_archiver_crypt_key }} diff --git a/templates/mailman.cfg.j2 b/templates/mailman.cfg.j2 index 443e578..8853dac 100644 --- a/templates/mailman.cfg.j2 +++ b/templates/mailman.cfg.j2 @@ -248,3 +248,9 @@ jump_chain: hold class: mailman.runners.nntp.NNTPRunner start: {{ mailman_start_nntp_runner }} +{% if mailman_use_hyperkitty_archiver | bool %} +[archiver.hyperkitty] +class: mailman_hyperkitty.Archiver +enable: yes +configuration: {{ mailman_conf_dir }}/mailman-hyperkitty.cfg +{% endif %} \ No newline at end of file diff --git a/templates/postorious_settings.py.j2 b/templates/postorious_settings.py.j2 index 6bc8eb4..8e2adba 100644 --- a/templates/postorious_settings.py.j2 +++ b/templates/postorious_settings.py.j2 @@ -262,25 +262,20 @@ LOGOUT_URL = 'account_logout' # otherwise the emails may get rejected. # https://docs.djangoproject.com/en/1.8/ref/settings/#default-from-email # DEFAULT_FROM_EMAIL = "mailing-lists@you-domain.org" -DEFAULT_FROM_EMAIL = 's2i2s@isti.cnr.it' +DEFAULT_FROM_EMAIL = '{{ mailman_from_email }}' # If you enable email reporting for error messages, this is where those emails # will appear to be coming from. Make sure you set a valid domain name, # otherwise the emails may get rejected. # https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-SERVER_EMAIL # SERVER_EMAIL = 'root@your-domain.org' -SERVER_EMAIL = 'mailman@isti.cnr.it' +SERVER_EMAIL = '{{ mailman_server_email }}' # Change this when you have a real email backend #EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -#EMAIL_HOST = 'smtp-srv.isti.cnr.it' -#EMAIL_PORT = 587 -#EMAIL_HOST_USER = 'mailman-svc' -#EMAIL_HOST_PASSWORD = '4e544458bcb74a8' -#EMAIL_USE_TLS = True -EMAIL_HOST = '127.0.0.1' -EMAIL_PORT = 25 +EMAIL_HOST = '{{ mailman_smtp_host }}' +EMAIL_PORT = {{ mailman_smtp_port }} EMAIL_USE_TLS = False # Compatibility with Bootstrap 3 @@ -305,6 +300,7 @@ ACCOUNT_EMAIL_VERIFICATION = "mandatory" ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https" ACCOUNT_UNIQUE_EMAIL = True +{% if mailman_use_social_account_providers %} SOCIALACCOUNT_PROVIDERS = { 'openid': { 'SERVERS': [ @@ -331,6 +327,9 @@ SOCIALACCOUNT_PROVIDERS = { 'VERSION': 'v2.4', }, } +{% else %} +SOCIALACCOUNT_PROVIDERS = { '' } +{% endif %} # # Gravatar @@ -461,16 +460,16 @@ LOGGING = { #}, } - +{% if mailman_use_memcache %} # Using the cache infrastructure can significantly improve performance on a # production setup. This is an example with a local Memcached server. -#CACHES = { -# 'default': { -# 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', -# 'LOCATION': '127.0.0.1:11211', -# } -#} - +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', + 'LOCATION': '{{ mailman_memcache_hosts }}', + } +} +{% endif %} # When DEBUG is True, don't actually send emails to the SMTP server, just store # them in a directory. This way you won't accidentally spam your mailing-lists