diff options
Diffstat (limited to 'manifests/pip.pp')
-rw-r--r-- | manifests/pip.pp | 24 |
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, } |