puppet_vardir.rb 937 B

1234567891011121314151617181920212223242526
  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. begin
  8. require 'facter/util/puppet_settings'
  9. rescue LoadError => e
  10. # puppet apply does not add module lib directories to the $LOAD_PATH (See
  11. # #4248). It should (in the future) but for the time being we need to be
  12. # defensive which is what this rescue block is doing.
  13. rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
  14. load rb_file if File.exists?(rb_file) or raise e
  15. end
  16. Facter.add(:puppet_vardir) do
  17. setcode do
  18. # This will be nil if Puppet is not available.
  19. Facter::Util::PuppetSettings.with_puppet do
  20. Puppet[:vardir]
  21. end
  22. end
  23. end