Skip to content

Commit 94d9ca5

Browse files
committed
Merge pull request voxpupuli#2 from mfournier/gunicorn_and_virtualenv_additions
Gunicorn and virtualenv additions
2 parents 91b595d + e7f975a commit 94d9ca5

6 files changed

Lines changed: 33 additions & 5 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,14 @@ Creates Python virtualenv.
6464

6565
**proxy** — Proxy server to use for outbound connections. Default: none
6666

67+
**systempkgs** — Copy system site-packages into virtualenv. Default: don't
68+
6769
python::virtualenv { '/var/www/project1':
6870
ensure => present,
6971
version => 'system',
7072
requirements => '/var/www/project1/requirements.txt',
7173
proxy => 'http://proxy.domain.com:3128',
74+
systempkgs => true,
7275
}
7376

7477
### python::gunicorn
@@ -87,15 +90,20 @@ Manages Gunicorn virtual hosts.
8790

8891
**environment** — Set ENVIRONMENT variable. Default: none
8992

93+
**template** — Which ERB template to use. Default: python/gunicorn.erb
94+
9095
python::gunicorn { 'vhost':
9196
ensure => present,
9297
virtualenv => '/var/www/project1',
9398
mode => 'wsgi',
9499
dir => '/var/www/project1/current',
95100
bind => 'unix:/tmp/gunicorn.socket',
96101
environment => 'prod',
102+
template => 'python/gunicorn.erb',
97103
}
98104

99105
## Authors
100106

101107
[Sergey Stankevich](https://github.com/stankevich)
108+
[Ashley Penney](https://github.com/apenney)
109+
[Marc Fournier](https://github.com/mfournier)

manifests/gunicorn.pp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
# [*environment*]
2626
# Set ENVIRONMENT variable. Default: none
2727
#
28+
# [*template*]
29+
# Which ERB template to use. Default: python/gunicorn.erb
30+
#
2831
# === Examples
2932
#
3033
# python::gunicorn { 'vhost':
@@ -34,20 +37,23 @@
3437
# dir => '/var/www/project1/current',
3538
# bind => 'unix:/tmp/gunicorn.socket',
3639
# environment => 'prod',
40+
# template => 'python/gunicorn.erb',
3741
# }
3842
#
3943
# === Authors
4044
#
4145
# Sergey Stankevich
46+
# Ashley Penney
47+
# Marc Fournier
4248
#
4349
define python::gunicorn (
4450
$ensure = present,
4551
$virtualenv = false,
4652
$mode = 'wsgi',
4753
$dir = false,
4854
$bind = false,
49-
$app_interface = 'wsgi',
5055
$environment = false,
56+
$template = 'python/gunicorn.erb',
5157
) {
5258

5359
# Parameter validation
@@ -60,7 +66,7 @@
6066
mode => '0644',
6167
owner => 'root',
6268
group => 'root',
63-
content => template('python/gunicorn.erb'),
69+
content => template($template),
6470
}
6571

6672
}

manifests/requirements.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# === Authors
2121
#
2222
# Sergey Stankevich
23+
# Ashley Penney
2324
#
2425
define python::requirements (
2526
$virtualenv = 'system',
@@ -38,7 +39,6 @@
3839
default => "--proxy=${proxy}",
3940
}
4041

41-
$req_dir = inline_template('<%= requirements.match(%r!(.+)/.+!)[1] %>')
4242
$req_crc = "${requirements}.sha1"
4343

4444
file { $requirements:

manifests/virtualenv.pp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,31 @@
1616
# [*proxy*]
1717
# Proxy server to use for outbound connections. Default: none
1818
#
19+
# [*systempkgs*]
20+
# Copy system site-packages into virtualenv. Default: don't
21+
#
1922
# === Examples
2023
#
2124
# python::virtualenv { '/var/www/project1':
2225
# ensure => present,
2326
# version => 'system',
2427
# requirements => '/var/www/project1/requirements.txt',
2528
# proxy => 'http://proxy.domain.com:3128',
29+
# systempkgs => true,
2630
# }
2731
#
2832
# === Authors
2933
#
3034
# Sergey Stankevich
35+
# Ashley Penney
36+
# Marc Fournier
3137
#
3238
define python::virtualenv (
3339
$ensure = present,
3440
$version = 'system',
3541
$requirements = false,
36-
$proxy = false
42+
$proxy = false,
43+
$systempkgs = false,
3744
) {
3845

3946
$venv_dir = $name
@@ -55,10 +62,15 @@
5562
default => "&& export http_proxy=${proxy}",
5663
}
5764

65+
$system_pkgs_flag = $systempkgs ? {
66+
false => '',
67+
default => '--system-site-packages',
68+
}
69+
5870
exec { "python_virtualenv_${venv_dir}":
5971
command => "mkdir -p ${venv_dir} \
6072
${proxy_command} \
61-
&& virtualenv -p `which ${python}` ${venv_dir} \
73+
&& virtualenv -p `which ${python}` ${system_pkgs_flag} ${venv_dir} \
6274
&& ${venv_dir}/bin/pip install ${proxy_flag} --upgrade distribute pip",
6375
creates => $venv_dir,
6476
}

tests/gunicorn.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
dir => '/var/www/project1/current',
1212
bind => 'unix:/tmp/gunicorn.socket',
1313
environment => 'prod',
14+
template => 'python/gunicorn.erb',
1415
}

tests/virtualenv.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
version => 'system',
1010
requirements => '/var/www/project1/requirements.txt',
1111
proxy => 'http://proxy.domain.com:3128',
12+
systempkgs => true,
1213
}

0 commit comments

Comments
 (0)