From 7c53014b9a3d605ce58819aea1c213b326605494 Mon Sep 17 00:00:00 2001 From: genofire Date: Fri, 24 Jul 2020 15:08:50 +0200 Subject: [PATCH] add mailman2 --- defaults/main.yml | 3 ++ handlers/main.yml | 3 ++ tasks/mailman.yml | 24 ++++++++++++++- templates/mailman_cfg.py | 66 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 templates/mailman_cfg.py diff --git a/defaults/main.yml b/defaults/main.yml index c628223..9a7f99b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -27,3 +27,6 @@ mailserver_rspamd_domain: "" mailserver_rspamd_dkim_selector: "2020" mailserver_mailman_enabled: true +mailserver_mailman_domains: +- mail: "lists.{{ mailserver_mail_domain }}" + web: "lists.{{ mailserver_mail_domain }}" diff --git a/handlers/main.yml b/handlers/main.yml index ef46014..1a06cdc 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -14,6 +14,9 @@ name: rspamd state: restarted +- name: mailman genaliases + command: /usr/lib/mailman/bin/genaliases + - name: reload postfix systemd: name: postfix diff --git a/tasks/mailman.yml b/tasks/mailman.yml index 7283a36..c808485 100644 --- a/tasks/mailman.yml +++ b/tasks/mailman.yml @@ -1,5 +1,27 @@ -- name: Install Mailman +- name: mailman - install package: state: latest name: - mailman + +- name: mailman - mm_config + notify: + - mailman genaliases + - reload postfix + template: + src: mailman_cfg.py + dest: /etc/mailman/mm_cfg.py + +- name: mailman - enable timer + systemd: + name: "{{ item }}" + state: started + enabled: yes + with_items: + - mailman-checkdbs.timer + - mailman-disabled.timer + - mailman-mailpasswds.timer + - mailman-senddigests.timer + - mailman-cullbadshunt.timer + - mailman-gatenews.timer + - mailman-nightlygzip.timer diff --git a/templates/mailman_cfg.py b/templates/mailman_cfg.py new file mode 100644 index 0000000..411e103 --- /dev/null +++ b/templates/mailman_cfg.py @@ -0,0 +1,66 @@ +# -*- python -*- + +# Copyright (C) 1998-2018 by the Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +"""This module contains your site-specific settings. + +From a brand new distribution it should be copied to mm_cfg.py. If you +already have an mm_cfg.py, be careful to add in only the new settings you +want. Mailman's installation procedure will never overwrite your mm_cfg.py +file. + +The complete set of distributed defaults, with documentation, are in the file +Defaults.py. In mm_cfg.py, override only those you want to change, after the + + from Defaults import * + +line (see below). + +Note that these are just default settings; many can be overridden via the +administrator and user interfaces on a per-list or per-user basis. + +Also note that many of these settings will not be effective until Mailman +is restarted. Thus, you should always restart Mailman after changing this +file. + +Further, settings which relate to a list's host_name and web_page_url only +affect lists created after the change. For existing lists, see the FAQ at +. + +""" + +############################################### +# Here's where we get the distributed defaults. + +from Defaults import * + +################################################## +# Put YOUR site-specific settings below this line. +MTA = 'Postfix' + +DEFAULT_EMAIL_HOST = '{{ mailserver_mailman_domains[0].mail }}' +DEFAULT_URL_HOST = '{{ mailserver_mailman_domains[0].web }}' + +VIRTUAL_HOSTS.clear() +{% for domain in mailserver_mailman_domains %} +add_virtualhost('{{ domain.web }}', '{{ domain.mail }}') +{% endfor %} + +POSTFIX_STYLE_VIRTUAL_DOMAINS = ['{{ mailserver_mailman_domains | map(attribute='mail') | join('\', \'') }}'] + +DEFAULT_URL_PATTERN = 'https://%s/' +PUBLIC_ARCHIVE_URL = 'https://%(hostname)s/archives/%(listname)s'