]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/recipes/default.rb
Configure elasticsearch disk thresholds on ironbelly
[chef.git] / cookbooks / hardware / recipes / default.rb
index f19446969c2d33c11f0f28b8ed81faa91ae8a5b2..d976e89dccbfa9bc702f9867d74c39610a0b8758 100644 (file)
@@ -120,6 +120,24 @@ unless unit.nil?
   end
 end
 
+# if we need a different / special kernel version to make the hardware
+# work (e.g: https://github.com/openstreetmap/operations/issues/45) then
+# ensure that we have the package installed. the grub template will
+# make sure that this is the default on boot.
+if node[:hardware][:grub][:kernel]
+  kernel_version = node[:hardware][:grub][:kernel]
+
+  package "linux-image-#{kernel_version}-generic"
+  package "linux-image-extra-#{kernel_version}-generic"
+  package "linux-headers-#{kernel_version}-generic"
+
+  boot_device = IO.popen(["df", "/boot"]).readlines.last.split.first
+  boot_uuid = IO.popen(["blkid", "-o", "value", "-s", "UUID", boot_device]).readlines.first.chomp
+  grub_entry = "gnulinux-advanced-#{boot_uuid}>gnulinux-#{kernel_version}-advanced-#{boot_uuid}"
+else
+  grub_entry = "0"
+end
+
 if File.exist?("/etc/default/grub")
   execute "update-grub" do
     action :nothing
@@ -131,7 +149,7 @@ if File.exist?("/etc/default/grub")
     owner "root"
     group "root"
     mode 0644
-    variables :unit => unit, :speed => speed
+    variables :unit => unit, :speed => speed, :entry => grub_entry
     notifies :run, "execute[update-grub]"
   end
 end
@@ -332,6 +350,8 @@ if status_packages["sas2ircu-status"]
     bus = host.sub("/sys/class/scsi_host/host", "")
 
     Dir.glob("/sys/bus/scsi/devices/#{bus}:0:*/scsi_generic/*").each do |sg|
+      next if File.directory?("#{sg}/../../block")
+
       disks << { :device => File.basename(sg) }
     end
   end