summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/facter/pip_version.rb19
-rw-r--r--manifests/pip.pp11
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}",