Another shot at this facts thing
[mirror/dsa-puppet.git] / facts / raidcontroller.rb
diff --git a/facts/raidcontroller.rb b/facts/raidcontroller.rb
new file mode 100644 (file)
index 0000000..5ec322a
--- /dev/null
@@ -0,0 +1,15 @@
+Facter.add("raidcontroller") do
+        confine :kernel => :linux
+        ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin"
+        setcode do
+                controllers = []
+                lspciexists = system "/bin/bash -c 'which lspci >&/dev//null'"
+                if $?.exitstatus == 0
+                        output = %x{lspci}
+                        output.each { |s|
+                                controllers.push($1) if s =~ /RAID bus controller: (.*)/
+                        }
+                end
+                controllers
+        end
+end