]> git.openstreetmap.org Git - chef.git/commitdiff
Enable SNMP for HostedIn.NZ machines
authorTom Hughes <tom@compton.nu>
Tue, 26 Feb 2019 00:07:32 +0000 (00:07 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 26 Feb 2019 00:14:56 +0000 (00:14 +0000)
cookbooks/snmpd/recipes/default.rb
cookbooks/snmpd/templates/default/snmpd.conf.erb
roles/hostedinnz.rb

index fd852357f39518cdc1a3c394d2d93102f84e2764..b5bccce4be4fbdbb97df675acef1de42ed9e82b5 100644 (file)
@@ -37,11 +37,23 @@ template "/etc/snmp/snmpd.conf" do
   notifies :restart, "service[snmpd]"
 end
 
   notifies :restart, "service[snmpd]"
 end
 
-node[:snmpd][:clients].each do |address|
+if node[:snmpd][:clients]
+  node[:snmpd][:clients].each do |address|
+    firewall_rule "accept-snmp" do
+      action :accept
+      family "inet"
+      source "net:#{address}"
+      dest "fw"
+      proto "udp"
+      dest_ports "snmp"
+      source_ports "1024:"
+    end
+  end
+else
   firewall_rule "accept-snmp" do
     action :accept
     family "inet"
   firewall_rule "accept-snmp" do
     action :accept
     family "inet"
-    source "net:#{address}"
+    source "net"
     dest "fw"
     proto "udp"
     dest_ports "snmp"
     dest "fw"
     proto "udp"
     dest_ports "snmp"
index acddef7368dbbedb8d36b03ab84d3e2d9c3f6556..9239fbd309aaa7a90836264e51edd436578b0521 100644 (file)
@@ -2,4 +2,6 @@
 
 rocommunity     <%= @communities[node[:snmpd][:community]] %>
 syslocation     <%= node[:snmpd][:location] %>
 
 rocommunity     <%= @communities[node[:snmpd][:community]] %>
 syslocation     <%= node[:snmpd][:location] %>
+<% if node[:snmpd][:contact] -%>
 syscontact      <%= node[:snmpd][:contact] %>
 syscontact      <%= node[:snmpd][:contact] %>
+<% end -%>
index 86438e01fadcebd7c8a1057d7595a91e9bafd198..40eaba9cc8c7b16a1b236d63809cda21a30a9acd 100644 (file)
@@ -11,6 +11,10 @@ default_attributes(
         :zone => "osm"
       }
     }
         :zone => "osm"
       }
     }
+  },
+  :snmpd => {
+    :community => "hostedinnz",
+    :location => "Wellington"
   }
 )
 
   }
 )
 
@@ -21,5 +25,6 @@ override_attributes(
 )
 
 run_list(
 )
 
 run_list(
-  "role[nz]"
+  "role[nz]",
+  "recipe[snmpd]"
 )
 )