summaryrefslogtreecommitdiff
path: root/lib/facter/virtualenv_version.rb
blob: 327b2ca2e5d6a9934b6552b8aee2cdaf3fc1c0df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Show the virtualenv version
# works with virualenv loaded and without, pip installed and package installed
require 'puppet'
pkg = Puppet::Type.type(:package).new(:name => "virtualenv")
Facter.add("virtualenv_version") do
  has_weight 100
  setcode do
    Facter::Util::Resolution.exec('virtualenv --version')
  end
end

Facter.add("virtualenv_version") do
  has_eight 50
  setcode do
    if pkg.retrieve[pkg.property(:ensure)] != 'purged'
        /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
    end
  end
end