From 9adc044f1a358c7a2e6df4ef719473deb1af28d0 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Tue, 24 Mar 2015 08:05:57 -0400 Subject: [PATCH] Add support for adding environment variables --- README.md | 3 +++ defaults/main.yml | 1 + templates/uwsgi/app_uwsgi.ini | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index ce3859f..4febbba 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ into sections and described below: - app_uwsgi_executable: - The method executed by UWSGI to create a WSGI running app. Usually a WSGI factory method or module in the app. - Default: app:make_wsgi_app() +- app_uwsgi_envs: + - (Optional) A dictionary of environment variables to pass into an app. + - Default: empty dictionary ### General Web: diff --git a/defaults/main.yml b/defaults/main.yml index ae59fbd..d45601c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,3 +15,4 @@ app_nginx_static_path: "{{ app_root_path }}/{{ app_name }}/static/" # UWSGI app_uwsgi_port: 8000 app_uwsgi_executable: "app:make_wsgi_app()" +app_uwsgi_envs: {} diff --git a/templates/uwsgi/app_uwsgi.ini b/templates/uwsgi/app_uwsgi.ini index 84ba7ff..f66a20e 100644 --- a/templates/uwsgi/app_uwsgi.ini +++ b/templates/uwsgi/app_uwsgi.ini @@ -6,3 +6,7 @@ processes = 8 chdir = {{ app_root_path }} virtualenv = {{ app_venv }} module = {{ app_uwsgi_executable }} + +{% for env_var, env_value in app_uwsgi_envs.items() %} +env = {{ env_var | upper }}={{ env_value }} +{% endfor %}