forked from voxpupuli/puppet-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgunicorn.pp
More file actions
107 lines (103 loc) · 2.58 KB
/
gunicorn.pp
File metadata and controls
107 lines (103 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# == Define: python::gunicorn
#
# Manages Gunicorn virtual hosts.
#
# === Parameters
#
# [*ensure*]
# present|absent. Default: present
#
# [*virtualenv*]
# Run in virtualenv, specify directory. Default: disabled
#
# [*mode*]
# Gunicorn mode.
# wsgi|django. Default: wsgi
#
# [*dir*]
# Application directory.
#
# [*bind*]
# Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'.
# Default: system-wide: unix:/tmp/gunicorn-$name.socket
# virtualenv: unix:${virtualenv}/${name}.socket
#
# [*environment*]
# Set ENVIRONMENT variable. Default: none
#
# [*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
#
# [*timeout*]
# Allows setting the gunicorn idle worker process time before being killed.
# The unit of time is seconds.
# Default: 30
#
# [*template*]
# Which ERB template to use. Default: python/gunicorn.erb
#
# [*args*]
# Custom arguments to add in gunicorn config file. Default: []
#
# === Examples
#
# python::gunicorn { 'vhost':
# ensure => present,
# virtualenv => '/var/www/project1',
# mode => 'wsgi',
# dir => '/var/www/project1/current',
# bind => 'unix:/tmp/gunicorn.socket',
# environment => 'prod',
# owner => 'www-data',
# group => 'www-data',
# appmodule => 'app:app',
# osenv => { 'DBHOST' => 'dbserver.example.com' },
# timeout => 30,
# template => 'python/gunicorn.erb',
# }
#
# === Authors
#
# Sergey Stankevich
# Ashley Penney
# Marc Fournier
#
define python::gunicorn (
$ensure = present,
$virtualenv = false,
$mode = 'wsgi',
$dir = false,
$bind = false,
$environment = false,
$owner = 'www-data',
$group = 'www-data',
$appmodule = 'app:app',
$osenv = false,
$timeout = 30,
$workers = false,
$access_log_format = false,
$accesslog = false,
$errorlog = false,
$log_level = 'error',
$template = 'python/gunicorn.erb',
$args = [],
) {
# Parameter validation
if ! $dir {
fail('python::gunicorn: dir parameter must not be empty')
}
validate_re($log_level, 'debug|info|warning|error|critical', "Invalid \$log_level value ${log_level}")
file { "/etc/gunicorn.d/${name}":
ensure => $ensure,
mode => '0644',
owner => 'root',
group => 'root',
content => template($template),
}
}