Created
July 5, 2012 19:01
-
-
Save devicenull/3055719 to your computer and use it in GitHub Desktop.
Puppet raidcontroller fact
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Facter.add("raidcontroller", :timeout => 10) do # Terminate the fact if resolution takes too long | |
confine :kernel => :linux | |
setcode do | |
controllers = [] | |
if output = Facter::Util::Resolution.exec('lspci') # Use facter's built in execution | |
output.each {|s| | |
controllers.push("megaraid") if s =~ /RAID bus controller: .* MegaRAID .*/ | |
controllers.push("3ware") if s =~ /RAID bus controller: 3ware .*/ | |
} | |
end | |
if FileTest.exists?("/proc/mdstat") | |
txt = File.read("/proc/mdstat") | |
controllers.push("software") if txt =~ /^md/i | |
end | |
controllers.join(",") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment