diff options
author | Jarl Stefansson <jarl@sdelements.com> | 2013-11-07 18:46:52 -0500 |
---|---|---|
committer | Jarl Stefansson <jarl@sdelements.com> | 2013-11-07 18:46:52 -0500 |
commit | 2e3784ba2c93f8240648682ce0b3c14bcb8605a7 (patch) | |
tree | 6cbaea760785bde990951dd58ba1fa4aa2ac42be | |
parent | 99a7bbbf8a0d4db3a2abba9f4a47ac65c223bbaa (diff) |
Added latest support to pip, fixed log param
--log-file is not supported in older versions, changed to use --log
Added ability to do pip --upgrade by using latest
-rw-r--r-- | lib/facter/pip_version.rb | 19 | ||||
-rw-r--r-- | manifests/pip.pp | 11 |
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/facter/pip_version.rb b/lib/facter/pip_version.rb new file mode 100644 index 0000000..48dd0bf --- /dev/null +++ b/lib/facter/pip_version.rb @@ -0,0 +1,19 @@ +# Make pip version available as a fact +# Works with pip loaded and without, pip installed using pip and package installed +require 'puppet' +pkg = Puppet::Type.type(:package).new(:name => "python-pip") +Facter.add("pip_version") do + has_weight 100 + setcode do + Facter::Util::Resolution.exec('pip --version') + end +end + +Facter.add("pip_version") do + has_weight 50 + setcode do + if pkg.retrieve[pkg.property(:ensure)] != 'purged' + /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + end +end diff --git a/manifests/pip.pp b/manifests/pip.pp index 9589b1a..0bed6dc 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -80,7 +80,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log-file ${cwd}/pip.log install ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -88,6 +88,15 @@ define python::pip ( } } + latest: { + exec { "pip_install_${name}": + command => "$pip_env --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", + user => $owner, + environment => $environment, + path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + } + } + default: { exec { "pip_uninstall_${name}": command => "echo y | $pip_env uninstall ${proxy_flag} ${name}", |