summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/mailman/files/django_fedora.py17
-rw-r--r--roles/mailman/tasks/main.yml11
-rw-r--r--roles/mailman/templates/settings.py.j217
3 files changed, 42 insertions, 3 deletions
diff --git a/roles/mailman/files/django_fedora.py b/roles/mailman/files/django_fedora.py
new file mode 100644
index 000000000..0f2751964
--- /dev/null
+++ b/roles/mailman/files/django_fedora.py
@@ -0,0 +1,17 @@
+from django.core.exceptions import DisallowedHost
+from django.http import UnreadablePostError
+from pylibmc import Error as MemcachedError
+
+EXCLUDED = (
+ DisallowedHost,
+ UnreadablePostError,
+ MemcachedError,
+)
+
+def exclude_useless_errors(record):
+ if record.exc_info:
+ exc_type, exc_value = record.exc_info[:2]
+ for excluded_class in EXCLUDED:
+ if isinstance(exc_value, EXCLUDED):
+ return False
+ return True
diff --git a/roles/mailman/tasks/main.yml b/roles/mailman/tasks/main.yml
index ef69b167f..3350238db 100644
--- a/roles/mailman/tasks/main.yml
+++ b/roles/mailman/tasks/main.yml
@@ -5,6 +5,7 @@
#
# SELinux
+# TODO: switch to the sefcontext module when we update Ansible to 2.2+
#
- name: install semanage
yum: pkg=policycoreutils-python state=present
@@ -266,6 +267,16 @@
- config
- mailman
+- name: install the django_fedora module
+ copy: src=django_fedora.py
+ dest="{{ mailman_webui_confdir }}/django_fedora.py"
+ owner=root group=root mode=0644
+ tags:
+ - config
+ - mailman
+ notify:
+ - reload apache
+
- name: install the hyperkitty urls file
copy: src=urls.py
dest="{{ mailman_webui_confdir }}/urls.py"
diff --git a/roles/mailman/templates/settings.py.j2 b/roles/mailman/templates/settings.py.j2
index 13fda3abb..f7043822e 100644
--- a/roles/mailman/templates/settings.py.j2
+++ b/roles/mailman/templates/settings.py.j2
@@ -6,6 +6,8 @@ Django settings for HyperKitty + Postorius
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
+import django_fedora
+
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{{ mailman_hyperkitty_cookie_key }}'
@@ -29,7 +31,7 @@ ALLOWED_HOSTS = [
".fedoraproject.org",
"localhost", # Archiving API from Mailman
"127.0.0.1", # HAProxy ping
- "mailman01", # Varnish ping on STG
+ "{{ ansible_hostname }}", # Varnish ping
]
# Mailman API credentials
@@ -322,12 +324,16 @@ LOGGING = {
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
+ },
+ 'exclude_useless_errors': {
+ '()': 'django.utils.log.CallbackFilter',
+ 'callback': django_fedora.exclude_useless_errors,
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
- 'filters': ['require_debug_false'],
+ 'filters': ['require_debug_false', 'exclude_useless_errors'],
'class': 'django.utils.log.AdminEmailHandler'
},
'file':{
@@ -340,7 +346,12 @@ LOGGING = {
},
'loggers': {
'django.request': {
- 'handlers': ['mail_admins', 'file'],
+ 'handlers': [
+ 'file',
+ {% if env == 'prod' %}
+ 'mail_admins',
+ {% endif %}
+ ],
'level': 'DEBUG',
'propagate': True,
},