More work on automatic installation of raid tools
authorTom Hughes <tom@compton.nu>
Wed, 6 Nov 2013 00:45:50 +0000 (00:45 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 6 Nov 2013 09:57:59 +0000 (09:57 +0000)
cookbooks/hardware/attributes/default.rb
cookbooks/hardware/recipes/default.rb
cookbooks/hardware/templates/default/raid.default.erb [new file with mode: 0644]

index 24dc2505d2f845f4e7eb375b663ca2091a3e7ebc..6b12827ca64a4cd0ec3941943c2f3fddcbac67ba 100644 (file)
@@ -10,15 +10,9 @@ if node[:dmi] and node[:dmi][:system]
 end
 
 if node[:kernel] and node[:kernel][:modules]
-  if node[:kernel][:modules].include?("mpt2sas")
-    default[:apt][:sources] |= [ "hwraid" ]
-  end
-
-  if node[:kernel][:modules].include?("megaraid_sas")
-    default[:apt][:sources] |= [ "hwraid" ]
-  end
+  raidmods = node[:kernel][:modules].keys & ["cciss", "mptsas", "mpt2sas", "megaraid_mm", "megaraid_sas", "aacraid"]
 
-  if node[:kernel][:modules].include?("aacraid")
+  unless raidmods.empty?
     default[:apt][:sources] |= [ "hwraid" ]
   end
 end
index e9fe54e053d2d6bedd3a7e8752b5ad3e6b093b3b..a602852539a66b8575ac4967bbba7da7fda1fa49 100644 (file)
@@ -40,7 +40,6 @@ case manufacturer
 when "HP"
   package "hponcfg"
   package "hp-health"
-  package "hpacucli"
   unit = "1"
   speed = "115200"
 when "TYAN"
@@ -142,17 +141,55 @@ template "/etc/initramfs-tools/conf.d/mdadm" do
   notifies :run, "execute[update-initramfs]"
 end
 
-if node[:kernel][:modules].include?("mpt2sas")
-  package "sas2ircu"
-  package "sas2ircu-status"
-end
+["cciss", "mptsas", "mpt2sas", "megaraid_mm", "megaraid_sas", "aacraid"].each do |raidmod|
+  case raidmod
+  when "cciss"
+    tools_package = "hpacucli"
+    status_package = "cciss-vol-status"
+  when "mptsas"
+    tools_package = "lsiutil"
+    status_package = "mpt-status"
+  when "mpt2sas"
+    tools_package = "sas2ircu"
+    status_package = "sas2ircu-status"
+  when "megaraid_mm"
+    tools_package = "megactl"
+    status_package = "megaraid-status"
+  when "megaraid_sas"
+    tools_package = "megacli"
+    status_package = "megaclisas-status"
+  when "aacraid"
+    tools_package = "arcconf"
+    status_package = "aacraid-status"
+  end
 
-if node[:kernel][:modules].include?("megaraid_sas")
-  package "megacli"
-  package "megaclisas-status"
-end
+  if node[:kernel][:modules].include?(raidmod)
+    package tools_package
+    package status_package
+
+    template "/etc/default/#{status_package}d" do
+      source "raid.default.erb"
+      owner "root"
+      group "root"
+      mode 0644
+    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
+    package status_package do
+      action :purge
+    end
+
+    package tools_package do
+      action :purge
+    end
 
-if node[:kernel][:modules].include?("aacraid")
-  package "arcconf"
-  package "aacraid-status"
+    file "/etc/default/#{status_package}d" do
+      action :delete
+    end
+  end
 end
diff --git a/cookbooks/hardware/templates/default/raid.default.erb b/cookbooks/hardware/templates/default/raid.default.erb
new file mode 100644 (file)
index 0000000..e72dc9c
--- /dev/null
@@ -0,0 +1 @@
+MAILTO=admins@openstreetmap.org