]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/lib/facter/puppet_vardir.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / lib / facter / puppet_vardir.rb
1 # This facter fact returns the value of the Puppet vardir setting for the node
2 # running puppet or puppet agent.  The intent is to enable Puppet modules to
3 # automatically have insight into a place where they can place variable data,
4 # regardless of the node's platform.
5 #
6 # The value should be directly usable in a File resource path attribute.
7
8
9 begin
10   require 'facter/util/puppet_settings'
11 rescue LoadError => e
12   # puppet apply does not add module lib directories to the $LOAD_PATH (See
13   # #4248). It should (in the future) but for the time being we need to be
14   # defensive which is what this rescue block is doing.
15   rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
16   load rb_file if File.exists?(rb_file) or raise e
17 end
18
19 Facter.add(:puppet_vardir) do
20   setcode do
21     # This will be nil if Puppet is not available.
22     Facter::Util::PuppetSettings.with_puppet do
23       Puppet[:vardir]
24     end
25   end
26 end