Skip to content

Instantly share code, notes, and snippets.

@evgeni
Created June 21, 2013 10:36
Show Gist options
  • Save evgeni/5830379 to your computer and use it in GitHub Desktop.
Save evgeni/5830379 to your computer and use it in GitHub Desktop.
Facter.add(:disks) do
confine :kernel => :linux
setcode do
disks = []
Dir.glob("/sys/block/*/device").each do |d|
d = d.split('/')[3]
if File.open('/sys/block/%s/removable' % d).readline.strip == '0'
disks.push(d)
end
end
disks.sort.uniq.join(',')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment