Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ Creates Python virtualenv.

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

**systempkgs** — Copy system site-packages into virtualenv. Default: don't

python::virtualenv { '/var/www/project1':
ensure => present,
version => 'system',
requirements => '/var/www/project1/requirements.txt',
proxy => 'http://proxy.domain.com:3128',
systempkgs => true,
}

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

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

**template** — Which ERB template to use. Default: python/gunicorn.erb

python::gunicorn { 'vhost':
ensure => present,
virtualenv => '/var/www/project1',
mode => 'wsgi',
dir => '/var/www/project1/current',
bind => 'unix:/tmp/gunicorn.socket',
environment => 'prod',
template => 'python/gunicorn.erb',
}

## Authors

[Sergey Stankevich](https://github.com/stankevich)
[Ashley Penney](https://github.com/apenney)
[Marc Fournier](https://github.com/mfournier)
10 changes: 8 additions & 2 deletions manifests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
# [*environment*]
# Set ENVIRONMENT variable. Default: none
#
# [*template*]
# Which ERB template to use. Default: python/gunicorn.erb
#
# === Examples
#
# python::gunicorn { 'vhost':
Expand All @@ -34,20 +37,23 @@
# dir => '/var/www/project1/current',
# bind => 'unix:/tmp/gunicorn.socket',
# environment => 'prod',
# template => 'python/gunicorn.erb',
# }
#
# === Authors
#
# Sergey Stankevich
# Ashley Penney
# Marc Fournier
#
define python::gunicorn (
$ensure = present,
$virtualenv = false,
$mode = 'wsgi',
$dir = false,
$bind = false,
$app_interface = 'wsgi',
$environment = false,
$template = 'python/gunicorn.erb',
) {

# Parameter validation
Expand All @@ -60,7 +66,7 @@
mode => '0644',
owner => 'root',
group => 'root',
content => template('python/gunicorn.erb'),
content => template($template),
}

}
2 changes: 1 addition & 1 deletion manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# === Authors
#
# Sergey Stankevich
# Ashley Penney
#
define python::requirements (
$virtualenv = 'system',
Expand All @@ -38,7 +39,6 @@
default => "--proxy=${proxy}",
}

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

file { $requirements:
Expand Down
16 changes: 14 additions & 2 deletions manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,31 @@
# [*proxy*]
# Proxy server to use for outbound connections. Default: none
#
# [*systempkgs*]
# Copy system site-packages into virtualenv. Default: don't
#
# === Examples
#
# python::virtualenv { '/var/www/project1':
# ensure => present,
# version => 'system',
# requirements => '/var/www/project1/requirements.txt',
# proxy => 'http://proxy.domain.com:3128',
# systempkgs => true,
# }
#
# === Authors
#
# Sergey Stankevich
# Ashley Penney
# Marc Fournier
#
define python::virtualenv (
$ensure = present,
$version = 'system',
$requirements = false,
$proxy = false
$proxy = false,
$systempkgs = false,
) {

$venv_dir = $name
Expand All @@ -55,10 +62,15 @@
default => "&& export http_proxy=${proxy}",
}

$system_pkgs_flag = $systempkgs ? {
false => '',
default => '--system-site-packages',
}

exec { "python_virtualenv_${venv_dir}":
command => "mkdir -p ${venv_dir} \
${proxy_command} \
&& virtualenv -p `which ${python}` ${venv_dir} \
&& virtualenv -p `which ${python}` ${system_pkgs_flag} ${venv_dir} \
&& ${venv_dir}/bin/pip install ${proxy_flag} --upgrade distribute pip",
creates => $venv_dir,
}
Expand Down
1 change: 1 addition & 0 deletions tests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
dir => '/var/www/project1/current',
bind => 'unix:/tmp/gunicorn.socket',
environment => 'prod',
template => 'python/gunicorn.erb',
}
1 change: 1 addition & 0 deletions tests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
version => 'system',
requirements => '/var/www/project1/requirements.txt',
proxy => 'http://proxy.domain.com:3128',
systempkgs => true,
}