]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/munin/recipes/default.rb
Modernise more LWRPs
[chef.git] / cookbooks / munin / recipes / default.rb
index fb98079315f593c6c5a70350ad3e54815067a2be..0fddea5a96ee475d275b78230989b6bacecd62dd 100644 (file)
 package "munin-node"
 
 service "munin-node" do
 package "munin-node"
 
 service "munin-node" do
-  if node[:lsb][:release].to_f >= 15.10
-    provider Chef::Provider::Service::Systemd
-  elsif node[:lsb][:release].to_f >= 14.04
-    provider Chef::Provider::Service::Upstart
-  end
   action [:enable, :start]
   supports :status => true, :restart => true, :reload => true
 end
   action [:enable, :start]
   supports :status => true, :restart => true, :reload => true
 end
@@ -97,7 +92,7 @@ else
 end
 
 munin_plugin_conf "df" do
 end
 
 munin_plugin_conf "df" do
-  template "df.erb"
+  template_source "df.erb"
 end
 
 munin_plugin "df"
 end
 
 munin_plugin "df"
@@ -162,9 +157,11 @@ end
 
 node[:network][:interfaces].each do |ifname, ifattr|
   if ifattr[:encapsulation] == "Ethernet" && ifattr[:state] == "up"
 
 node[:network][:interfaces].each do |ifname, ifattr|
   if ifattr[:encapsulation] == "Ethernet" && ifattr[:state] == "up"
-    if node[:hardware][:network][ifname][:device] =~ /^virtio/
+    if node[:hardware] &&
+       node[:hardware][:network] &&
+       node[:hardware][:network][ifname][:device] =~ /^virtio/
       munin_plugin_conf "if_#{ifname}" do
       munin_plugin_conf "if_#{ifname}" do
-        template "if.erb"
+        template_source "if.erb"
         variables :ifname => ifname
       end
     else
         variables :ifname => ifname
       end
     else
@@ -210,11 +207,10 @@ if Dir.glob("/dev/ipmi*").empty?
 
   munin_plugin "ipmi_power" do
     action :delete
 
   munin_plugin "ipmi_power" do
     action :delete
-    only_if { node[:lsb][:release].to_f >= 14.04 }
   end
 else
   munin_plugin_conf "ipmi" do
   end
 else
   munin_plugin_conf "ipmi" do
-    template "ipmi.erb"
+    template_source "ipmi.erb"
   end
 
   munin_plugin "ipmi_fans" do
   end
 
   munin_plugin "ipmi_fans" do
@@ -227,7 +223,6 @@ else
 
   munin_plugin "ipmi_power" do
     target "ipmi_"
 
   munin_plugin "ipmi_power" do
     target "ipmi_"
-    only_if { node[:lsb][:release].to_f >= 14.04 }
   end
 end
 
   end
 end
 
@@ -291,9 +286,7 @@ Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
   sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
 end
 
   sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
 end
 
-if sensors_fan || sensors_temp || sensors_volt
-  package "lm-sensors"
-end
+package "lm-sensors" if sensors_fan || sensors_temp || sensors_volt
 
 if sensors_fan
   munin_plugin "sensors_fan" do
 
 if sensors_fan
   munin_plugin "sensors_fan" do