]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/recipes/default.rb
Enable hardware watchdog support on more machines
[chef.git] / cookbooks / hardware / recipes / default.rb
index 5e48994764716fc93232bcdddeabbac66fed82a4..d77aebacd248cf0710dca8b780fa99dbf431309c 100644 (file)
@@ -28,6 +28,10 @@ ohai_plugin "hardware" do
   template "ohai.rb.erb"
 end
 
+if platform?("debian")
+  package "firmware-linux"
+end
+
 if node[:cpu] && node[:cpu][:"0"] && node[:cpu][:"0"][:vendor_id]
   case node[:cpu][:"0"][:vendor_id]
   when "GenuineIntel"
@@ -222,6 +226,10 @@ else
   end
 end
 
+watchdog_module = %w[hpwdt sp5100_tco].find do |module_name|
+  node[:hardware][:pci].any? { |_, pci| pci[:modules]&.any?(module_name) }
+end
+
 if node[:kernel][:modules].include?("ipmi_si")
   package "ipmitool"
   package "freeipmi-tools"
@@ -242,6 +250,8 @@ if node[:kernel][:modules].include?("ipmi_si")
     options "--config.file=/etc/prometheus/ipmi_local.yml"
     subscribes :restart, "template[/etc/prometheus/ipmi_local.yml]"
   end
+
+  watchdog_module ||= "ipmi_watchdog"
 end
 
 package "irqbalance"
@@ -605,19 +615,30 @@ node[:hardware][:blacklisted_modules].each do |module_name|
   end
 end
 
-if node[:hardware][:watchdog]
-  package "watchdog"
+if watchdog_module
+  kernel_module watchdog_module do
+    action :install
+  end
+
+  execute "systemctl-reload" do
+    action :nothing
+    command "systemctl daemon-reload"
+    user "root"
+    group "root"
+  end
 
-  template "/etc/default/watchdog" do
-    source "watchdog.erb"
+  directory "/etc/systemd/system.conf.d" do
     owner "root"
     group "root"
-    mode "644"
-    variables :module => node[:hardware][:watchdog]
+    mode "755"
   end
 
-  service "watchdog" do
-    action [:enable, :start]
+  template "/etc/systemd/system.conf.d/watchdog.conf" do
+    source "watchdog.conf.erb"
+    owner "root"
+    group "root"
+    mode "644"
+    notifies :run, "execute[systemctl-reload]"
   end
 end