summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Stankevich <stankevich@users.noreply.github.com>2014-04-08 10:13:49 -0400
committerSergey Stankevich <stankevich@users.noreply.github.com>2014-04-08 10:13:49 -0400
commit8ba358b22e04773d37132b2288a62130b0fe747c (patch)
tree02fff38f71831c41813b009b19628118f0cb6837
parentc3a5a8f338776255859d50f4b906642f540cb162 (diff)
parentc3aa0cf84cdbc5ddb85de5d3fc9c2636d1eb633f (diff)
Merge pull request #78 from codesplicer/master
Make venv_dir into a class parameter
-rw-r--r--manifests/virtualenv.pp35
1 files changed, 18 insertions, 17 deletions
diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp
index 2faa809..419e2ae 100644
--- a/manifests/virtualenv.pp
+++ b/manifests/virtualenv.pp
@@ -16,7 +16,8 @@
# [*systempkgs*]
# Copy system site-packages into virtualenv. Default: don't
# If virtualenv version < 1.7 this flag has no effect since
-# the system packages were not supported
+# [*venv_dir*]
+# Directory to install virtualenv to. Default: $name
#
# [*distribute*]
# Include distribute in the virtualenv. Default: true
@@ -64,23 +65,22 @@
# Fotis Gimian
#
define python::virtualenv (
- $ensure = present,
- $version = 'system',
- $requirements = false,
- $systempkgs = false,
- $distribute = true,
- $index = false,
- $owner = 'root',
- $group = 'root',
- $proxy = false,
- $environment = [],
- $path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ],
- $cwd = undef,
- $timeout = 1800
+ $ensure = present,
+ $version = 'system',
+ $requirements = false,
+ $systempkgs = false,
+ $venv_dir = $name,
+ $distribute = true,
+ $index = false,
+ $owner = 'root',
+ $group = 'root',
+ $proxy = false,
+ $environment = [],
+ $path = [ '/bin', '/usr/bin', '/usr/sbin' ],
+ $cwd = undef,
+ $timeout = 1800
) {
- $venv_dir = $name
-
if $ensure == 'present' {
$python = $version ? {
@@ -130,8 +130,9 @@ define python::virtualenv (
exec { "python_virtualenv_${venv_dir}":
command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg} || ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg} ;}",
user => $owner,
+ creates => "${venv_dir}/bin/activate",
path => $path,
- cwd => "/tmp",
+ cwd => '/tmp',
environment => $environment,
unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv
}