Merge ~kotodama/mojo/+git/mojo-specs:mailman3-core-charm into ~mojo-maintainers/mojo/+git/mojo-specs:master

Proposed by Loïc Gomez
Status: Superseded
Proposed branch: ~kotodama/mojo/+git/mojo-specs:mailman3-core-charm
Merge into: ~mojo-maintainers/mojo/+git/mojo-specs:master
Diff against target: 256 lines (+220/-0)
6 files modified
charm-testing/mailman3-core/collect (+8/-0)
charm-testing/mailman3-core/deploy (+58/-0)
charm-testing/mailman3-core/files/arbitrary_config (+47/-0)
charm-testing/mailman3-core/files/check-lists.conf (+13/-0)
charm-testing/mailman3-core/files/policyd-spf.conf (+10/-0)
charm-testing/mailman3-core/templates/check_list_settings.py.tmpl (+84/-0)
Reviewer Review Type Date Requested Status
Mojo Maintainers Pending
Review via email: mp+407977@code.launchpad.net

Commit message

Initial collect and deploy for mailman3-core charm testing

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Tom Haddon (mthaddon) wrote :

A few comments inline

Revision history for this message
Tom Haddon (mthaddon) wrote :

Some comments inline

Unmerged commits

e35aaff... by Loïc Gomez

Initial collect and deploy for mailman3-core charm testing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charm-testing/mailman3-core/collect b/charm-testing/mailman3-core/collect
2new file mode 100644
3index 0000000..0a923cc
4--- /dev/null
5+++ b/charm-testing/mailman3-core/collect
6@@ -0,0 +1,8 @@
7+apache2 cs:apache2
8+mailman3-core cs:mailman3-core
9+mailman3-web cs:mailman3-web
10+postgresql cs:postgresql;overwrite=True
11+
12+# subordinates
13+nrpe cs:nrpe
14+ntp cs:ntp
15diff --git a/charm-testing/mailman3-core/deploy b/charm-testing/mailman3-core/deploy
16new file mode 100644
17index 0000000..7bf9448
18--- /dev/null
19+++ b/charm-testing/mailman3-core/deploy
20@@ -0,0 +1,58 @@
21+mailman3-core:
22+ series: {{series}}
23+ services:
24+ apache2:
25+ charm: apache2
26+ options:
27+ servername: lists.ci.internal
28+ enable_modules: headers proxy proxy_http rewrite ssl
29+ mailman3-core:
30+ charm: mailman3-core
31+ options:
32+ hostname: lists-mx.ci.internal
33+ site_owner: devnull@canonical.com
34+ spf_config: include-file://{{spec_dir}}/{{stage}}/files/policyd-spf.conf
35+ enable_strict_host_checks: "test"
36+ mailman3-web:
37+ charm: mailman3-web
38+ num_units: 2
39+ expose: true
40+ options:
41+ domain: lists-mx.ci.internal
42+ site_name: CI Canonical Mailing Lists
43+ extra_packages: "django-mailman-launchpad-teams python-contextlib2 python-django-openid-auth python-raven"
44+ install_sources: '["ppa:canonical-sysadmins/django-mailman-launchpad-teams"]'
45+ additional_django_apps: "'django_openid_auth', 'django_mailman_launchpad_teams'"
46+ arbitrary_django_settings: include-file://{{spec_dir}}/{{stage}}/files/arbitrary_config
47+ check-lists-command: include-base64://{{spec_dir}}/{{stage}}/templates/check_list_settings.py.tmpl
48+ check-lists-conf: include-base64://{{spec_dir}}/{{stage}}/files/check-lists.conf
49+ postgresql:
50+ charm: postgresql
51+
52+ # subordinates
53+ nrpe:
54+ charm: nrpe
55+ options:
56+ nagios_master: nagios1.internal
57+ nagios_host_context: ci-lists-canonical
58+ swap: -w 40% -c 25% -n ok
59+ ntp:
60+ charm: ntp
61+ options:
62+ pools: ntp.ubuntu.com
63+
64+ relations:
65+ - ["apache2:balancer", "mailman3-web:mailman3website"]
66+ - ["mailman3-core:mailman3", "mailman3-web:mailman3"]
67+ - ["mailman3-web:mailman3archiver", "mailman3-core:mailman3archiver"]
68+ - ["nrpe:nrpe-external-master", "apache2"]
69+ - ["nrpe:nrpe-external-master", "mailman3-core:nrpe-external-master"]
70+ - ["nrpe:nrpe-external-master", "mailman3-web:nrpe-external-master"]
71+ - ["nrpe:nrpe-external-master", "ntp:nrpe-external-master"]
72+ - ["nrpe:nrpe-external-master", "postgresql:nrpe-external-master"]
73+ - ["ntp:juju-info", "apache2"]
74+ - ["ntp:juju-info", "mailman3-core"]
75+ - ["ntp:juju-info", "mailman3-web"]
76+ - ["ntp:juju-info", "postgresql"]
77+ - ["postgresql:db", "mailman3-core:db"]
78+ - ["postgresql:db", "mailman3-web:db"]
79diff --git a/charm-testing/mailman3-core/files/arbitrary_config b/charm-testing/mailman3-core/files/arbitrary_config
80new file mode 100644
81index 0000000..8e5691f
82--- /dev/null
83+++ b/charm-testing/mailman3-core/files/arbitrary_config
84@@ -0,0 +1,47 @@
85+MIDDLEWARE_CLASSES = (
86+ 'django.contrib.sessions.middleware.SessionMiddleware',
87+ 'django.middleware.common.CommonMiddleware',
88+ 'django.middleware.csrf.CsrfViewMiddleware',
89+ 'django.middleware.locale.LocaleMiddleware',
90+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
91+ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
92+ 'django.contrib.messages.middleware.MessageMiddleware',
93+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
94+ 'django.middleware.security.SecurityMiddleware',
95+ 'django_mailman3.middleware.TimezoneMiddleware',
96+ 'postorius.middleware.PostoriusMiddleware',
97+ 'django_mailman_launchpad_teams.middleware.RequireLoginMiddleware',
98+ )
99+
100+AUTHENTICATION_BACKENDS = (
101+ 'django_openid_auth.auth.OpenIDBackend',
102+ 'django.contrib.auth.backends.ModelBackend',
103+ )
104+
105+# Can OpenID create users?
106+OPENID_CREATE_USERS = True
107+# Can we reuser existing users?
108+OPENID_REUSE_USERS = True
109+# When logging in again, should we overwrite user details based on
110+# data received via Simple Registration?
111+OPENID_UPDATE_DETAILS_FROM_SREG = True
112+# If set, always use this as the identity URL rather than asking the
113+# user. This only makes sense if it is a server URL.
114+OPENID_SSO_SERVER_URL = 'https://login.ubuntu.com'
115+OPENID_LAUNCHPAD_TEAMS_REQUIRED = ["mojo-maintainers"]
116+OPENID_LAUNCHPAD_STAFF_TEAMS = ["mojo-maintainers"]
117+OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO = True
118+# Tell django.contrib.auth to use the OpenID signin URLs.
119+LOGIN_URL = 'openid-login'
120+LOGIN_REDIRECT_URL = '/'
121+LOGIN_REQUIRED_URLS = (
122+ r'(.*)',
123+ )
124+LOGIN_REQUIRED_URLS_EXCEPTIONS = (
125+ r'/mailman3/openid(.*)$',
126+ r'/mailman3/hyperkitty/api(.*)$',
127+ )
128+SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
129+ALLOWED_EXTERNAL_OPENID_REDIRECT_DOMAINS = ['*']
130+ROOT_URLCONF = 'django_mailman_launchpad_teams.urls'
131+
132diff --git a/charm-testing/mailman3-core/files/check-lists.conf b/charm-testing/mailman3-core/files/check-lists.conf
133new file mode 100644
134index 0000000..4ea13b0
135--- /dev/null
136+++ b/charm-testing/mailman3-core/files/check-lists.conf
137@@ -0,0 +1,13 @@
138+[list_sanity]
139+
140+external_subscriber_lists:
141+ fake-external
142+
143+not_archived_lists:
144+ fake-not-arch
145+
146+do_not_accept_all_canonical_posts:
147+ fake-restricted
148+
149+private:
150+ fake-private
151diff --git a/charm-testing/mailman3-core/files/policyd-spf.conf b/charm-testing/mailman3-core/files/policyd-spf.conf
152new file mode 100644
153index 0000000..c20b46c
154--- /dev/null
155+++ b/charm-testing/mailman3-core/files/policyd-spf.conf
156@@ -0,0 +1,10 @@
157+debugLevel = 1
158+defaultSeedOnly = 1
159+
160+HELO_reject = SPF_Not_Pass
161+Mail_From_reject = Fail
162+
163+PermError_reject = False
164+TempError_Defer = False
165+
166+skip_addresses = 127.0.0.0/8,::ffff:127.0.0.0/104,::1/128
167diff --git a/charm-testing/mailman3-core/templates/check_list_settings.py.tmpl b/charm-testing/mailman3-core/templates/check_list_settings.py.tmpl
168new file mode 100644
169index 0000000..ef4365f
170--- /dev/null
171+++ b/charm-testing/mailman3-core/templates/check_list_settings.py.tmpl
172@@ -0,0 +1,84 @@
173+import sys
174+
175+from django_mailman3.lib.mailman import get_mailman_client
176+from django.core.management.base import BaseCommand
177+from django.utils.six.moves.urllib.error import HTTPError
178+from mailmanclient import MailmanConnectionError
179+
180+from ConfigParser import ConfigParser
181+
182+NAGIOS_OK = 0
183+NAGIOS_WARN = 1
184+NAGIOS_FAIL = 2
185+
186+
187+class nagios_warning:
188+ def __init__(self):
189+ self.warning = ""
190+
191+ def add(self, line):
192+ self.warning += line + "\n"
193+
194+
195+class SeriousConfigParser(ConfigParser):
196+ def get_list(self, section, option, raw=False, vars=None):
197+ """Look up OPTION in SECTION and return it as a list of words."""
198+ return self.get(section, option, raw, vars).split()
199+
200+
201+class Command(BaseCommand):
202+
203+ def get_mm_lists(self, client):
204+ try:
205+ mm_lists = client.get_lists()
206+ except (MailmanConnectionError, HTTPError):
207+ print("E: could not connect to mailman3-core to retrieve lists")
208+ sys.exit(NAGIOS_FAIL)
209+ if mm_lists is None:
210+ print("E: could not retrieve lists from mailman3-core")
211+ sys.exit(NAGIOS_FAIL)
212+ return mm_lists
213+
214+ def check_list(self, ccc, mlist, warning):
215+ ret_val = NAGIOS_OK
216+
217+ # Rules are as follows:
218+ # All lists must require subscription confirmation by the user
219+ # Must be archived or explicitly excepted in the check config
220+ # Either fully private or public
221+ # If they have external subscribers, must be named list-external or excepted in the config
222+ # Private lists must be explicitly listed in the check config
223+
224+ if mlist.settings['subscription_policy'] not in ['confirm', 'confirm_then_moderate']:
225+ print("E: list '%s' doesn't require subscription confirmation" % (mlist.list_name))
226+ ret_val = NAGIOS_FAIL
227+
228+ if 'never' in mlist.settings['archive_policy'] and mlist.list_name.lower() not in not_archived_lists:
229+ warning.add("WARN: %s is not archived and not in not_archived_lists in /etc/nagios/check-lists.conf"
230+ % mlist.list_name.lower())
231+
232+ return ret_val
233+
234+ def add_arguments(self, parser):
235+ parser.add_argument("--verbose", action="store_true", dest="verbose")
236+
237+ def handle(self, *args, **options):
238+
239+ warning = nagios_warning()
240+
241+ ccc = SeriousConfigParser()
242+ ccc.readfp(file("/etc/nagios/check-lists.conf"))
243+
244+ client = get_mailman_client()
245+ mlists = self.get_mm_lists(client)
246+
247+ ret_val = NAGIOS_OK
248+ for mlist in mlists:
249+ ret = self.check_list(ccc, mlist, warning)
250+ ret_val = max([ret_val, ret])
251+ if ret_val == NAGIOS_FAIL:
252+ sys.exit(ret_val)
253+
254+ if options['verbose'] and warning.warning:
255+ print(warning.warning,)
256+ sys.exit(NAGIOS_WARN)

Subscribers

People subscribed via source and target branches

to all changes: