]> git.openstreetmap.org Git - chef.git/blob - cookbooks/hardware/recipes/default.rb
Add hardware cookbook
[chef.git] / cookbooks / hardware / recipes / default.rb
1 #
2 # Cookbook Name:: hardware
3 # Recipe:: default
4 #
5 # Copyright 2012, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 case node[:cpu][:"0"][:vendor_id]
21 when "GenuineIntel"
22   package "intel-microcode"
23 end
24
25 if node[:dmi] and node[:dmi][:system]
26   case node[:dmi][:system][:manufacturer]
27   when "empty"
28     manufacturer = node[:dmi][:base_board][:manufacturer]
29     product = node[:dmi][:base_board][:product_name]
30   else
31     manufacturer = node[:dmi][:system][:manufacturer]
32     product = node[:dmi][:system][:product_name]
33   end
34 else
35   manufacturer = "Unknown"
36   product = "Unknown"
37 end
38
39 case manufacturer
40 when "HP"
41   package "hponcfg"
42   package "hp-health"
43   package "hpacucli"
44   unit = "1"
45   speed = "115200"
46 when "TYAN"
47   unit = "0"
48   speed = "115200"
49 when "TYAN Computer Corporation"
50   unit = "0"
51   speed = "115200"
52 when "Supermicro"
53   case product
54   when "H8DGU", "X9SCD", "X7DBU", "X7DW3", "X9DR7/E-(J)LN4F", "X9DR3-F"
55     unit = "1"
56     speed = "115200"
57   else
58     unit = "0"
59     speed = "115200"
60   end
61 when "IBM"
62   unit = "0"
63   speed = "115200"
64 end
65
66 if manufacturer == "HP" and node[:lsb][:release].to_f > 11.10
67   git "/opt/hp/hp-legacy" do
68     action :sync
69     repository "git://chef.openstreetmap.org/hp-legacy.git"
70     user "root"
71     group "root"
72   end
73
74   link "/opt/hp/hp-health/bin/hpasmd" do
75     to "/opt/hp/hp-legacy/hpasmd"
76   end
77
78   link "/usr/lib/libhpasmintrfc.so.3.0" do
79     to "/opt/hp/hp-legacy/libhpasmintrfc.so.3.0"
80   end
81
82   link "/usr/lib/libhpasmintrfc.so.3" do
83     to "libhpasmintrfc.so.3.0"
84   end
85
86   link "/usr/lib/libhpasmintrfc.so" do
87     to "libhpasmintrfc.so.3.0"
88   end
89 end
90
91 unless unit.nil?
92   file "/etc/init/ttySttyS#{unit}.conf" do
93     action :delete
94   end
95
96   template "/etc/init/ttyS#{unit}.conf" do
97     source "tty.conf.erb"
98     owner "root"
99     group "root"
100     mode 0644
101     variables :unit => unit, :speed => speed
102   end
103
104   service "ttyS#{unit}" do
105     provider Chef::Provider::Service::Upstart
106     action [ :enable, :start ]
107     supports :status => true, :restart => true, :reload => false
108     subscribes :restart, resources(:template => "/etc/init/ttyS#{unit}.conf")
109   end
110 end
111
112 if File.exist?("/etc/default/grub")
113   execute "update-grub" do
114     action :nothing
115     command "/usr/sbin/update-grub"
116   end
117
118   template "/etc/default/grub" do
119     source "grub.erb"
120     owner "root"
121     group "root"
122     mode 0644
123     variables :unit => unit, :speed => speed
124     notifies :run, resources(:execute => "update-grub")
125   end
126 end
127
128 execute "update-initramfs" do
129   action :nothing
130   command "update-initramfs -u -k all"
131   user "root"
132   group "root"
133 end
134
135 template "/etc/initramfs-tools/conf.d/mdadm" do
136   source "initramfs-mdadm.erb"
137   owner "root"
138   group "root"
139   mode 0644
140   notifies :run, "execute[update-initramfs]"
141 end
142
143 if node[:kernel][:modules].include?("mpt2sas")
144   package "sas2ircu"
145   package "sas2ircu-status"
146 end