Update puppetlabs/stdlib module
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / facter / package_provider.rb
1 # Fact: package_provider
2 #
3 # Purpose: Returns the default provider Puppet will choose to manage packages
4 #   on this system
5 #
6 # Resolution: Instantiates a dummy package resource and return the provider
7 #
8 # Caveats:
9 #
10 require 'puppet/type'
11 require 'puppet/type/package'
12
13 Facter.add(:package_provider) do
14   setcode do
15     if defined? Gem && Gem::Version.new(Facter.value(:puppetversion).split(' ')[0]) >= Gem::Version.new('3.6')
16       Puppet::Type.type(:package).newpackage(:name => 'dummy', :allow_virtual => 'true')[:provider].to_s
17     else
18       Puppet::Type.type(:package).newpackage(:name => 'dummy')[:provider].to_s
19     end
20   end
21 end