Skip to content

Instantly share code, notes, and snippets.

@devicenull
Created July 5, 2012 19:01
Show Gist options
  • Save devicenull/3055719 to your computer and use it in GitHub Desktop.
Save devicenull/3055719 to your computer and use it in GitHub Desktop.
Puppet raidcontroller fact
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