From 40ea2656f072e23bbbccd22c39fb29a36390fa3a Mon Sep 17 00:00:00 2001 From: Micah Date: Tue, 12 Jul 2016 16:46:08 -0400 Subject: git subrepo clone https://leap.se/git/puppet_stdlib puppet/modules/stdlib subrepo: subdir: "puppet/modules/stdlib" merged: "7112363" upstream: origin: "https://leap.se/git/puppet_stdlib" branch: "master" commit: "7112363" git-subrepo: version: "0.3.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "1e79595" Change-Id: I032e3e7c2984bf53b717373df495c039bb6f41b3 --- .../stdlib/lib/facter/util/puppet_settings.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 puppet/modules/stdlib/lib/facter/util/puppet_settings.rb (limited to 'puppet/modules/stdlib/lib/facter/util/puppet_settings.rb') diff --git a/puppet/modules/stdlib/lib/facter/util/puppet_settings.rb b/puppet/modules/stdlib/lib/facter/util/puppet_settings.rb new file mode 100644 index 00000000..1ad94521 --- /dev/null +++ b/puppet/modules/stdlib/lib/facter/util/puppet_settings.rb @@ -0,0 +1,21 @@ +module Facter + module Util + module PuppetSettings + # This method is intended to provide a convenient way to evaluate a + # Facter code block only if Puppet is loaded. This is to account for the + # situation where the fact happens to be in the load path, but Puppet is + # not loaded for whatever reason. Perhaps the user is simply running + # facter without the --puppet flag and they happen to be working in a lib + # directory of a module. + def self.with_puppet + begin + Module.const_get("Puppet") + rescue NameError + nil + else + yield + end + end + end + end +end -- cgit v1.2.3