X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/327d24752df2584f8d09837a8d30d60e901546fc..52e464a8e1bd7572fb865d12f1617666db15b072:/cookbooks/hardware/recipes/default.rb diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 2f8a4398e..8ba21da8b 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -297,10 +297,18 @@ end end end -disks = node[:hardware][:disk][:disks].map do |disk| +if node[:hardware][:disk] + disks = node[:hardware][:disk][:disks] +else + disks = [] +end + +disks = disks.map do |disk| + next if disk[:state] == "spun_down" + if disk[:smart_device] controller = node[:hardware][:disk][:controllers][disk[:controller]] - device = File.basename(controller[:device]) + device = controller[:device].sub("/dev/", "") smart = disk[:smart_device] if device.start_with?("cciss/") && smart =~ /^cciss,(\d+)$/ @@ -311,11 +319,13 @@ disks = node[:hardware][:disk][:disks].map do |disk| elsif smart =~ %r{^.*,(\d+)/(\d+)$} munin = "#{device}-#{Regexp.last_match(1)}:#{Regexp.last_match(2)}" end - else - device = File.basename(disk[:device]) + elsif disk[:device] + device = disk[:device].sub("/dev/", "") munin = device end + next if device.nil? + Hash[ :device => device, :smart => smart, @@ -324,6 +334,8 @@ disks = node[:hardware][:disk][:disks].map do |disk| ] end +disks = disks.compact + if disks.count > 0 package "smartmontools" @@ -431,7 +443,11 @@ if node[:lsb][:release].to_f <= 12.10 end else service "kmod" do - provider Chef::Provider::Service::Upstart + if node[:lsb][:release].to_f >= 15.10 + provider Chef::Provider::Service::Systemd + else + provider Chef::Provider::Service::Upstart + end action :nothing subscribes :start, "template[/etc/modules]" end