Add support for bonding and VLANs
[chef.git] / cookbooks / networking / recipes / default.rb
index 67d7bcf3e0ad667324e22fa87bffcd15c4a11c31..e23b1dae313b13beaed885d8edde69ed67d2fdca 100644 (file)
 
 require "ipaddr"
 
+network_packages = []
+
 node[:networking][:interfaces].each do |name, interface|
+  network_packages |= ["vlan"] if interface[:interface] =~ /\.\d+$/
+  network_packages |= ["ifenslave"] if interface[:bond]
+
   if interface[:role] && (role = node[:networking][:roles][interface[:role]])
     if role[interface[:family]]
-      node.set[:networking][:interfaces][name][:method] = role[interface[:family]][:method]
       node.set[:networking][:interfaces][name][:prefix] = role[interface[:family]][:prefix]
       node.set[:networking][:interfaces][name][:gateway] = role[interface[:family]][:gateway]
     end
@@ -34,16 +38,14 @@ node[:networking][:interfaces].each do |name, interface|
     node.set[:networking][:interfaces][name][:zone] = role[:zone]
   end
 
-  node.set_unless[:networking][:interfaces][name][:method] = "static"
-
-  next unless interface[:address]
-
   prefix = node[:networking][:interfaces][name][:prefix]
 
   node.set[:networking][:interfaces][name][:netmask] = (~IPAddr.new(interface[:address]).mask(0)).mask(prefix)
   node.set[:networking][:interfaces][name][:network] = IPAddr.new(interface[:address]).mask(prefix)
 end
 
+package network_packages
+
 template "/etc/network/interfaces" do
   source "interfaces.erb"
   owner "root"
@@ -212,7 +214,7 @@ firewall_rule "limit-icmp-echo" do
   rate_limit "s:1/sec:5"
 end
 
-%w(ucl ic bm).each do |zone|
+%w(ucl ic bm aws).each do |zone|
   firewall_rule "accept-openvpn-#{zone}" do
     action :accept
     family :inet