summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-04-20 11:52:43 -0500
committerLuke Kanies <luke@madstop.com>2009-04-20 16:48:34 -0500
commit516402c77f9c7d751c627db36885e12aaff62bf9 (patch)
treeb14e85124a3a599a478ba4046076d4e84aadabb1
parentd89ea7a88a93b6ce3132d9dd394b4187eb460cb2 (diff)
downloadfacter-516402c77f9c7d751c627db36885e12aaff62bf9.tar.gz
facter-516402c77f9c7d751c627db36885e12aaff62bf9.tar.xz
facter-516402c77f9c7d751c627db36885e12aaff62bf9.zip
Fixing #1918 - facter --puppet always works
The problem was that Facter wasn't telling Puppet to read your puppet.conf, so if you'd set vardir or libdir in it then you didn't get the appropriate settings and thus not know where to find the facter plugins. This is a bit of a ham-handed approach, but it always works. Signed-off-by: Luke Kanies <luke@madstop.com>
-rwxr-xr-xbin/facter15
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/facter b/bin/facter
index 6ee5b48..4ffd50a 100755
--- a/bin/facter
+++ b/bin/facter
@@ -58,6 +58,19 @@ rescue Exception
$haveusage = false
end
+def load_puppet
+ require 'puppet'
+ Puppet.parse_config
+
+ # If you've set 'vardir' but not 'libdir' in your
+ # puppet.conf, then the hook to add libdir to $:
+ # won't get triggered. This makes sure that it's setup
+ # correctly.
+ unless $LOAD_PATH.include?(Puppet[:libdir])
+ $LOAD_PATH << Puppet[:libdir]
+ end
+end
+
$debug = 0
config = nil
@@ -83,7 +96,7 @@ begin
exit
when "--puppet"
begin
- require 'puppet'
+ load_puppet()
rescue LoadError => detail
$stderr.puts "Could not load Puppet: %s" % detail
end