summaryrefslogtreecommitdiff
path: root/manifests/pip.pp
diff options
context:
space:
mode:
authorFotis Gimian <fgimiansoftware@gmail.com>2013-06-03 23:13:50 +1000
committerFotis Gimian <fgimiansoftware@gmail.com>2013-06-03 23:13:50 +1000
commit1aaef848f4a52d83a6b44eeb4cffd9b61a665c41 (patch)
treee064a68f8ddcdbad835dc1f561cd74fa4e832300 /manifests/pip.pp
parentf6fd9f46fe9c058d1f0877043d42829efe0c45cb (diff)
Made system virtualenv more robust and ensured that pip logging would occur in an appropriate directory upon failure to avoid errors
Diffstat (limited to 'manifests/pip.pp')
-rw-r--r--manifests/pip.pp24
1 files changed, 19 insertions, 5 deletions
diff --git a/manifests/pip.pp b/manifests/pip.pp
index 73f4cdc..0693057 100644
--- a/manifests/pip.pp
+++ b/manifests/pip.pp
@@ -28,7 +28,7 @@
# Sergey Stankevich
#
define python::pip (
- $virtualenv,
+ $virtualenv = 'system',
$ensure = present,
$url = false,
$owner = 'root',
@@ -42,6 +42,20 @@ define python::pip (
fail('python::pip: virtualenv parameter must not be empty')
}
+ if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') {
+ fail('python::pip: root user must be used when virtualenv is system')
+ }
+
+ $cwd = $virtualenv ? {
+ 'system' => '/',
+ default => "${virtualenv}",
+ }
+
+ $pip_env = $virtualenv ? {
+ 'system' => '`which pip`',
+ default => "${virtualenv}/bin/pip",
+ }
+
$proxy_flag = $proxy ? {
false => '',
default => "--proxy=${proxy}",
@@ -60,8 +74,8 @@ define python::pip (
case $ensure {
present: {
exec { "pip_install_${name}":
- command => "${virtualenv}/bin/pip install ${proxy_flag} ${source}",
- unless => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}",
+ command => "$pip_env --log-file ${cwd}/pip.log install ${proxy_flag} ${source}",
+ unless => "$pip_env freeze | grep -i -e ${grep_regex}",
user => $owner,
environment => $environment,
}
@@ -69,8 +83,8 @@ define python::pip (
default: {
exec { "pip_uninstall_${name}":
- command => "echo y | ${virtualenv}/bin/pip uninstall ${proxy_flag} ${name}",
- onlyif => "${virtualenv}/bin/pip freeze | grep -i -e ${grep_regex}",
+ command => "echo y | $pip_env uninstall ${proxy_flag} ${name}",
+ onlyif => "$pip_env freeze | grep -i -e ${grep_regex}",
user => $owner,
environment => $environment,
}