From d1b262484fcd7e00bbd3acce3c70bc2fe69df266 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr>
Date: Tue, 12 Sep 2017 22:17:02 +0200
Subject: [PATCH] add an ansible task to set DJANGO_SETTINGS_MODULE in wsgi
 handler script

this seems to be a shortcoming of mod_wsgi-express, which does not save
this var from the call to a line such as:
"./manage.py runmodwsgi --setup-only --settings=XXX"


Former-commit-id: 082479fde709b689a38e670927c367f0af29ca73
---
 ansible/deploy.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ansible/deploy.yaml b/ansible/deploy.yaml
index a333c9d6..c90a19d2 100644
--- a/ansible/deploy.yaml
+++ b/ansible/deploy.yaml
@@ -77,6 +77,12 @@
         command: "runmodwsgi --setup-only --port=80 --user ippidb --group wheel --server-root=/etc/ippidb-80"
         app_path: "/home/{{ deploy_user_name }}/iPPIDB/ippisite"
         settings: "ippisite.{{ ansible_hostname }}_settings"
+    - name: add line in generated WSGI handler script to set DJANGO_SETTINGS_MODULE
+      blockinfile:
+        path: /etc/ippidb-80/handler.wsgi
+        insertafter: "os.environ['MOD_WSGI_SERVER_ALIASES'] = None or ''"
+        content: |
+          os.environ['DJANGO_SETTINGS_MODULE'] = 'ippisite.{{ ansible_hostname }}_settings'
     - name: create or update database
       become_user: "{{ deploy_user_name }}"
       django_manage:
-- 
GitLab