X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/361ede788a09f6dd16b075d40f8b952493aafff8..b8b28fe06033fec880ba9b179e63387ed5a70fa0:/cookbooks/hardware/recipes/default.rb diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index c568cafd4..8c587d9f0 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -22,6 +22,13 @@ when "GenuineIntel" package "intel-microcode" end +case node[:cpu][:"0"][:vendor_id] +when "AuthenticAMD" + if node[:lsb][:release].to_f >= 14.04 + package "amd64-microcode" + end +end + if node[:dmi] and node[:dmi][:system] case node[:dmi][:system][:manufacturer] when "empty" @@ -50,7 +57,7 @@ when "TYAN Computer Corporation" speed = "115200" when "Supermicro" case product - when "H8DGU", "X9SCD", "X7DBU", "X7DW3", "X9DR7/E-(J)LN4F", "X9DR3-F" + when "H8DGU", "X9SCD", "X7DBU", "X7DW3", "X9DR7/E-(J)LN4F", "X9DR3-F", "X9DRW" unit = "1" speed = "115200" else @@ -106,7 +113,7 @@ unless unit.nil? provider Chef::Provider::Service::Upstart action [ :enable, :start ] supports :status => true, :restart => true, :reload => false - subscribes :restart, resources(:template => "/etc/init/ttyS#{unit}.conf") + subscribes :restart, "template[/etc/init/ttyS#{unit}.conf]" end end @@ -122,7 +129,7 @@ if File.exist?("/etc/default/grub") group "root" mode 0644 variables :unit => unit, :speed => speed - notifies :run, resources(:execute => "update-grub") + notifies :run, "execute[update-grub]" end end @@ -141,62 +148,178 @@ template "/etc/initramfs-tools/conf.d/mdadm" do notifies :run, "execute[update-initramfs]" end -["cciss", "hpsa", "mptsas", "mpt2sas", "megaraid_mm", "megaraid_sas", "aacraid"].each do |raidmod| - case raidmod +if node[:kernel][:modules].include?("ipmi_si") + package "ipmitool" +end + +if node[:lsb][:release].to_f >= 12.10 + package "irqbalance" + + template "/etc/default/irqbalance" do + source "irqbalance.erb" + owner "root" + group "root" + mode 0644 + end + + service "irqbalance" do + action [ :start, :enable ] + supports :status => false, :restart => true, :reload => false + subscribes :restart, "template[/etc/default/irqbalance]" + end +end + +tools_packages = [] +status_packages = {} + +node[:kernel][:modules].each_key do |modname| + case modname when "cciss" - tools_package = "hpacucli" - status_package = "cciss-vol-status" + tools_packages << "hpacucli" + status_packages["cciss-vol-status"] ||= [] when "hpsa" - tools_package = "hpacucli" + tools_packages << "hpacucli" + status_packages["cciss-vol-status"] ||= [] when "mptsas" - tools_package = "lsiutil" - status_package = "mpt-status" + tools_packages << "lsiutil" + #status_packages["mpt-status"] ||= [] when "mpt2sas" - tools_package = "sas2ircu" - status_package = "sas2ircu-status" + tools_packages << "sas2ircu" + status_packages["sas2ircu-status"] ||= [] when "megaraid_mm" - tools_package = "megactl" - status_package = "megaraid-status" + tools_packages << "megactl" + status_packages["megaraid-status"] ||= [] when "megaraid_sas" - tools_package = "megacli" - status_package = "megaclisas-status" + tools_packages << "megacli" + status_packages["megaclisas-status"] ||= [] when "aacraid" - tools_package = "arcconf" - status_package = "aacraid-status" + tools_packages << "arcconf" + status_packages["aacraid-status"] ||= [] end +end + +node[:block_device].each do |name,attributes| + if attributes[:vendor] == "HP" and attributes[:model] == "LOGICAL VOLUME" + if name =~ /^cciss!(c[0-9]+)d[0-9]+$/ + status_packages["cciss-vol-status"] |= [ "cciss/#{$1}d0" ] + else + Dir.glob("/sys/block/#{name}/device/scsi_generic/*").each do |sg| + status_packages["cciss-vol-status"] |= [ File.basename(sg) ] + end + end + end +end - if node[:kernel][:modules].include?(raidmod) +["hpacucli", "lsiutil", "sas2ircu", "megactl", "megacli", "arcconf"].each do |tools_package| + if tools_packages.include?(tools_package) package tools_package + else + package tools_package do + action :purge + end + end +end - if status_package - package status_package +["cciss-vol-status", "mpt-status", "sas2ircu-status", "megaraid-status", "megaclisas-status", "aacraid-status"].each do |status_package| + if status_packages.include?(status_package) + package status_package - template "/etc/default/#{status_package}d" do - source "raid.default.erb" - owner "root" - group "root" - mode 0644 - end + template "/etc/default/#{status_package}d" do + source "raid.default.erb" + owner "root" + group "root" + mode 0644 + variables :devices => status_packages[status_package] + end - service "#{status_package}d" do - action [ :start, :enable ] - supports :status => false, :restart => true, :reload => false - subscribes :restart, "template[/etc/default/#{status_package}d]" - end + service "#{status_package}d" do + action [ :start, :enable ] + supports :status => false, :restart => true, :reload => false + subscribes :restart, "template[/etc/default/#{status_package}d]" end else - if status_package - package status_package do - action :purge - end - - file "/etc/default/#{status_package}d" do - action :delete - end + package status_package do + action :purge end - package tools_package do - action :purge + file "/etc/default/#{status_package}d" do + action :delete end end end + +if File.exists?("/etc/mdadm/mdadm.conf") + mdadm_conf = edit_file "/etc/mdadm/mdadm.conf" do |line| + line.gsub!(/^MAILADDR .*$/, "MAILADDR admins@openstreetmap.org") + + line + end + + file "/etc/mdadm/mdadm.conf" do + owner "root" + group "root" + mode 0644 + content mdadm_conf + end + + service "mdadm" do + action :nothing + subscribes :restart, "file[/etc/mdadm/mdadm.conf]" + end +end + +template "/etc/modules" do + source "modules.erb" + owner "root" + group "root" + mode 0644 +end + +if node[:lsb][:release].to_f <= 12.10 + service "module-init-tools" do + provider Chef::Provider::Service::Upstart + action :nothing + subscribes :start, "template[/etc/modules]" + end +else + service "kmod" do + provider Chef::Provider::Service::Upstart + action :nothing + subscribes :start, "template[/etc/modules]" + end +end + +if node[:hardware][:watchdog] + package "watchdog" + + template "/etc/default/watchdog" do + source "watchdog.erb" + owner "root" + group "root" + mode 0644 + variables :module => node[:hardware][:watchdog] + end + + service "watchdog" do + action [ :enable, :start ] + end +end + +unless Dir.glob("/sys/class/hwmon/hwmon*").empty? + package "lm-sensors" + + execute "/etc/sensors.d/chef.conf" do + action :nothing + command "/usr/bin/sensors -s" + user "root" + group "root" + end + + template "/etc/sensors.d/chef.conf" do + source "sensors.conf.erb" + owner "root" + group "root" + mode 0644 + notifies :run, "execute[/etc/sensors.d/chef.conf]" + end +end