From 35f493f33d8b76289770e46029bb932523d263e4 Mon Sep 17 00:00:00 2001 From: Derek Tamsen Date: Tue, 21 Oct 2014 14:30:17 -0700 Subject: [PATCH 1/3] Adding osenv hash to set os environment vars for gunicorn --- manifests/gunicorn.pp | 1 + templates/gunicorn.erb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index 3c0a8bbd..e7d0aeba 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -63,6 +63,7 @@ $owner = 'www-data', $group = 'www-data', $appmodule = 'app:app', + $osenv = false, $template = 'python/gunicorn.erb', ) { diff --git a/templates/gunicorn.erb b/templates/gunicorn.erb index e1bb58b8..493a816e 100644 --- a/templates/gunicorn.erb +++ b/templates/gunicorn.erb @@ -6,6 +6,9 @@ CONFIG = { <% end -%> <% if @virtualenv -%> 'environment': { +<% if @osenv -%><% @osenv.sort.each do |key, value| -%> + '<%= key %>': '<%= value %>', +<% end -%><% end -%> <% if @environment -%> 'ENVIRONMENT': '<%= @environment %>', <% end -%> From 8e3d3e6af0e20d41075ece2090ebe3452a5d900a Mon Sep 17 00:00:00 2001 From: Derek Tamsen Date: Tue, 21 Oct 2014 14:43:48 -0700 Subject: [PATCH 2/3] fix indentation of settings file --- templates/gunicorn.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/gunicorn.erb b/templates/gunicorn.erb index 493a816e..5e565c8d 100644 --- a/templates/gunicorn.erb +++ b/templates/gunicorn.erb @@ -7,7 +7,7 @@ CONFIG = { <% if @virtualenv -%> 'environment': { <% if @osenv -%><% @osenv.sort.each do |key, value| -%> - '<%= key %>': '<%= value %>', + '<%= key %>': '<%= value %>', <% end -%><% end -%> <% if @environment -%> 'ENVIRONMENT': '<%= @environment %>', From 36243c3fd5e15d722644ffd639252c62b9cb03a7 Mon Sep 17 00:00:00 2001 From: Derek Tamsen Date: Tue, 21 Oct 2014 15:20:36 -0700 Subject: [PATCH 3/3] updating docs with new python::gunicorn osenv setting and updating tests for appmodule and osenv --- README.md | 3 +++ manifests/gunicorn.pp | 6 ++++++ tests/gunicorn.pp | 2 ++ 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 5150e103..8324c54a 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,8 @@ Manages Gunicorn virtual hosts. **appmodule** - Set the application module name for gunicorn to load when not using Django. Default: app:app +**osenv** - Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. Default: false + **template** - Which ERB template to use. Default: python/gunicorn.erb ```puppet @@ -185,6 +187,7 @@ Manages Gunicorn virtual hosts. bind => 'unix:/tmp/gunicorn.socket', environment => 'prod', appmodule => 'app:app', + osenv => { 'DBHOST' => 'dbserver.example.com' }, template => 'python/gunicorn.erb', } ``` diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index e7d0aeba..1cfdc015 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -29,6 +29,11 @@ # Set the application module name for gunicorn to load when not using Django. # Default: app:app # +# [*osenv*] +# Allows setting environment variables for the gunicorn service. Accepts a +# hash of 'key': 'value' pairs. +# Default: false +# # [*template*] # Which ERB template to use. Default: python/gunicorn.erb # @@ -44,6 +49,7 @@ # owner => 'www-data', # group => 'www-data', # appmodule => 'app:app', +# osenv => { 'DBHOST' => 'dbserver.example.com' }, # template => 'python/gunicorn.erb', # } # diff --git a/tests/gunicorn.pp b/tests/gunicorn.pp index c32ea1a2..4951c386 100644 --- a/tests/gunicorn.pp +++ b/tests/gunicorn.pp @@ -11,5 +11,7 @@ dir => '/var/www/project1/current', bind => 'unix:/tmp/gunicorn.socket', environment => 'prod', + appmodule => 'app:app', + osenv => { 'DBHOST' => 'dbserver.example.com' }, template => 'python/gunicorn.erb', }