Skip to content

Commit 7299cd1

Browse files
committed
Merge pull request voxpupuli#133 from derektamsen/20141021-add_osenv_feature
Allow setting os environment vars in python::gunicorn
2 parents fcc91ae + 36243c3 commit 7299cd1

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ Manages Gunicorn virtual hosts.
174174

175175
**appmodule** - Set the application module name for gunicorn to load when not using Django. Default: app:app
176176

177+
**osenv** - Allows setting environment variables for the gunicorn service. Accepts a hash of 'key': 'value' pairs. Default: false
178+
177179
**template** - Which ERB template to use. Default: python/gunicorn.erb
178180

179181
```puppet
@@ -185,6 +187,7 @@ Manages Gunicorn virtual hosts.
185187
bind => 'unix:/tmp/gunicorn.socket',
186188
environment => 'prod',
187189
appmodule => 'app:app',
190+
osenv => { 'DBHOST' => 'dbserver.example.com' },
188191
template => 'python/gunicorn.erb',
189192
}
190193
```

manifests/gunicorn.pp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
# Set the application module name for gunicorn to load when not using Django.
3030
# Default: app:app
3131
#
32+
# [*osenv*]
33+
# Allows setting environment variables for the gunicorn service. Accepts a
34+
# hash of 'key': 'value' pairs.
35+
# Default: false
36+
#
3237
# [*template*]
3338
# Which ERB template to use. Default: python/gunicorn.erb
3439
#
@@ -44,6 +49,7 @@
4449
# owner => 'www-data',
4550
# group => 'www-data',
4651
# appmodule => 'app:app',
52+
# osenv => { 'DBHOST' => 'dbserver.example.com' },
4753
# template => 'python/gunicorn.erb',
4854
# }
4955
#
@@ -63,6 +69,7 @@
6369
$owner = 'www-data',
6470
$group = 'www-data',
6571
$appmodule = 'app:app',
72+
$osenv = false,
6673
$template = 'python/gunicorn.erb',
6774
) {
6875

templates/gunicorn.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ CONFIG = {
66
<% end -%>
77
<% if @virtualenv -%>
88
'environment': {
9+
<% if @osenv -%><% @osenv.sort.each do |key, value| -%>
10+
'<%= key %>': '<%= value %>',
11+
<% end -%><% end -%>
912
<% if @environment -%>
1013
'ENVIRONMENT': '<%= @environment %>',
1114
<% end -%>

tests/gunicorn.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
dir => '/var/www/project1/current',
1212
bind => 'unix:/tmp/gunicorn.socket',
1313
environment => 'prod',
14+
appmodule => 'app:app',
15+
osenv => { 'DBHOST' => 'dbserver.example.com' },
1416
template => 'python/gunicorn.erb',
1517
}

0 commit comments

Comments
 (0)