]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/recipes/default.rb
Fix rubocop warnings
[chef.git] / cookbooks / hardware / recipes / default.rb
index 13e24b80db2b1db4909b55accde37bebf7a50e44..5d1757b46159b429e8088f1c7bead43070f5b7ef 100644 (file)
@@ -31,9 +31,7 @@ end
 
 case node[:cpu][:"0"][:vendor_id]
 when "AuthenticAMD"
-  if node[:lsb][:release].to_f >= 14.04
-    package "amd64-microcode"
-  end
+  package "amd64-microcode" if node[:lsb][:release].to_f >= 14.04
 end
 
 if node[:dmi] && node[:dmi][:system]
@@ -59,7 +57,20 @@ end
 case manufacturer
 when "HP"
   package "hponcfg"
-  package "hp-health"
+
+  # Downgrade hp-health to 10.0.0.1.3-4. as 10.40-1815.49 has issues with reliable startup
+  package "hp-health" do
+    action :install
+    version "10.0.0.1.3-4."
+    options "--force-yes"
+    notifies :restart, "service[hp-health]"
+  end
+
+  service "hp-health" do
+    action [:enable, :start]
+    supports :status => true, :restart => true
+  end
+
   units << "1"
 when "TYAN"
   units << "0"
@@ -76,6 +87,20 @@ when "IBM"
   units << "0"
 end
 
+# Remove legacy HP G4 support which breaks modern hp-health 10.4
+if manufacturer == "HP"
+  %w(/opt/hp/hp-health/bin/hpasmd /usr/lib/libhpasmintrfc.so.3.0 %/usr/lib/libhpasmintrfc.so.3 /usr/lib/libhpasmintrfc.so).each do |filename|
+    file filename do
+      action :delete
+    end
+  end
+
+  directory "/opt/hp/hp-legacy" do
+    action :delete
+    recursive true
+  end
+end
+
 units.sort.uniq.each do |unit|
   if node[:lsb][:release].to_f >= 16.04
     service "serial-getty@ttyS#{unit}" do
@@ -157,9 +182,7 @@ service "haveged" do
   action [:enable, :start]
 end
 
-if node[:kernel][:modules].include?("ipmi_si")
-  package "ipmitool"
-end
+package "ipmitool" if node[:kernel][:modules].include?("ipmi_si")
 
 if node[:lsb][:release].to_f >= 12.10
   package "irqbalance"
@@ -351,6 +374,12 @@ disks = disks.map do |disk|
   ]
 end
 
+smartd_service = if node[:lsb][:release].to_f >= 16.04
+                   "smartd"
+                 else
+                   "smartmontools"
+                 end
+
 disks = disks.compact
 
 if disks.count > 0
@@ -369,7 +398,6 @@ if disks.count > 0
     group "root"
     mode 0o644
     variables :disks => disks
-    notifies :reload, "service[smartmontools]"
   end
 
   template "/etc/default/smartmontools" do
@@ -377,12 +405,12 @@ if disks.count > 0
     owner "root"
     group "root"
     mode 0o644
-    notifies :restart, "service[smartmontools]"
   end
 
-  service "smartmontools" do
+  service smartd_service do
     action [:enable, :start]
-    supports :status => true, :restart => true, :reload => true
+    subscribes :reload, "template[/etc/smartd.conf]"
+    subscribes :restart, "template[/etc/default/smartmontools]"
   end
 
   # Don't try and do munin monitoring of disks behind
@@ -399,7 +427,7 @@ if disks.count > 0
     end
   end
 else
-  service "smartmontools" do
+  service smartd_service do
     action [:stop, :disable]
   end
 end