Facter.add('partinfo') do setcode do obj = {} Dir.entries('/sys/class/block/').each do |entry| if entry == '.' or entry == '..' then next end path = "/sys/class/block/#{entry}/partition" if File.file?(path) then obj[entry] = { 'partid' => File.read(path).strip(), 'device' => File.basename(File.dirname(File.readlink("/sys/class/block/#{entry}"))), } end end obj end end