From 809a2f4029561e921b4ae8a71d789583b8cc70e4 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 4 Mar 2024 19:18:27 +0000 Subject: [PATCH] Enable hardware watchdog on HP machines --- cookbooks/hardware/attributes/default.rb | 6 ---- cookbooks/hardware/recipes/default.rb | 29 ++++++++++++++----- .../templates/default/watchdog.conf.erb | 4 +++ .../hardware/templates/default/watchdog.erb | 7 ----- 4 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 cookbooks/hardware/templates/default/watchdog.conf.erb delete mode 100644 cookbooks/hardware/templates/default/watchdog.erb diff --git a/cookbooks/hardware/attributes/default.rb b/cookbooks/hardware/attributes/default.rb index 78ec107c7..218e6228e 100644 --- a/cookbooks/hardware/attributes/default.rb +++ b/cookbooks/hardware/attributes/default.rb @@ -37,12 +37,6 @@ if node[:kernel][:modules].include?("ipmi_si") end end -if File.exist?("/proc/xen") - default[:hardware][:watchdog] = "xen_wdt" -elsif node[:kernel][:modules].include?("i6300esb") - default[:hardware][:watchdog] = "none" -end - if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor") && File.read("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor").chomp == "ondemand" default[:sysfs][:cpufreq_ondemand][:comment] = "Tune the ondemand CPU frequency governor" diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index d7c508d9a..93891599a 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -120,6 +120,8 @@ when "HP", "HPE" else "1" end + + watchdog_module = "hpwdt" when "TYAN" units << "0" when "TYAN Computer Corporation" @@ -609,19 +611,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 diff --git a/cookbooks/hardware/templates/default/watchdog.conf.erb b/cookbooks/hardware/templates/default/watchdog.conf.erb new file mode 100644 index 000000000..187622f31 --- /dev/null +++ b/cookbooks/hardware/templates/default/watchdog.conf.erb @@ -0,0 +1,4 @@ +# DO NOT EDIT - This file is being maintained by Chef + +[Manager] +RuntimeWatchdogSec=60s diff --git a/cookbooks/hardware/templates/default/watchdog.erb b/cookbooks/hardware/templates/default/watchdog.erb deleted file mode 100644 index afeef4448..000000000 --- a/cookbooks/hardware/templates/default/watchdog.erb +++ /dev/null @@ -1,7 +0,0 @@ -# DO NOT EDIT - This file is being maintained by Chef - -# Start watchdog at boot time? 0 or 1 -run_watchdog=1 -# Load module before starting watchdog -watchdog_module="<%= @module %>" -# Specify additional watchdog options here (see manpage). -- 2.39.5