[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.7-1-98-gf19c0e5

Luke Kanies luke at madstop.com
Wed Apr 8 21:48:11 UTC 2009


The following commit has been merged in the master branch:
commit 39a8b28690377339d4c430ebf62cec5ef0ed34b8
Author: Luke Kanies <luke at madstop.com>
Date:   Thu Feb 12 22:58:57 2009 -0600

    Fixing #1964 - Facts get loaded from plugins
    
    Applying slightly modified patch.
    
    Also added tests.
    
    Signed-off-by: Luke Kanies <luke at madstop.com>

diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb
index 6ed89da..a026dfe 100644
--- a/lib/puppet/indirector/facts/facter.rb
+++ b/lib/puppet/indirector/facts/facter.rb
@@ -24,8 +24,12 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
     end
 
     def self.loadfacts
-        # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com] 
-        x = Puppet[:factpath].split(":").each do |dir|
+        # Add any per-module fact directories to the factpath
+        module_fact_dirs = Puppet[:modulepath].split(":").collect do |d|
+            Dir.glob("%s/*/plugins/facter" % d)
+        end.flatten
+        dirs = module_fact_dirs + Puppet[:factpath].split(":")
+        x = dirs.each do |dir|
             loaddir(dir, "fact")
         end
     end
diff --git a/spec/unit/indirector/facts/facter.rb b/spec/unit/indirector/facts/facter.rb
index 5dcc444..530e5a7 100755
--- a/spec/unit/indirector/facts/facter.rb
+++ b/spec/unit/indirector/facts/facter.rb
@@ -70,8 +70,9 @@ describe Puppet::Node::Facts::Facter do
         end
     end
 
-    describe Puppet::Node::Facts::Facter, "when loading facts from the factpath" do
-        it "should load each directory in the Fact path when loading fact" do
+    describe Puppet::Node::Facts::Facter, "when loading facts from disk" do
+        it "should load each directory in the Fact path" do
+            Puppet.settings.stubs(:value).returns "foo"
             Puppet.settings.expects(:value).with(:factpath).returns("one%stwo" % File::PATH_SEPARATOR)
 
             Puppet::Node::Facts::Facter.expects(:loaddir).with("one", "fact")
@@ -79,5 +80,22 @@ describe Puppet::Node::Facts::Facter do
 
             Puppet::Node::Facts::Facter.loadfacts
         end
+
+        it "should load all facts from the modules" do
+            Puppet.settings.stubs(:value).returns "foo"
+            Puppet::Node::Facts::Facter.stubs(:loaddir)
+
+            Puppet.settings.expects(:value).with(:modulepath).returns("one%stwo" % File::PATH_SEPARATOR)
+
+            Dir.expects(:glob).with("one/*/plugins/facter").returns %w{oneA oneB}
+            Dir.expects(:glob).with("two/*/plugins/facter").returns %w{twoA twoB}
+
+            Puppet::Node::Facts::Facter.expects(:loaddir).with("oneA", "fact")
+            Puppet::Node::Facts::Facter.expects(:loaddir).with("oneB", "fact")
+            Puppet::Node::Facts::Facter.expects(:loaddir).with("twoA", "fact")
+            Puppet::Node::Facts::Facter.expects(:loaddir).with("twoB", "fact")
+
+            Puppet::Node::Facts::Facter.loadfacts
+        end
     end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list