iface lo inet loopback
<% node[:networking][:interfaces].each do |name,interface| -%>
+<% if interface[:interface] -%>
+<% if interface[:bond] -%>
+<% interface[:bond][:slaves].each do |slave| -%>
-iface <%= interface[:interface] %> <%= interface[:family] %> <%= interface[:method] %>
-<% if interface[:address] -%>
- address <%= interface[:address] %>
+iface <%= slave %> inet manual
+ bond-master <%= interface[:interface] %>
+<% end -%>
+
+auto <%= interface[:bond][:slaves].sort.uniq.join(" ") %>
<% end -%>
+
+iface <%= interface[:interface] %> <%= interface[:family] %> static
+ address <%= interface[:address] %>
<% if interface[:family] == "inet" -%>
netmask <%= interface[:netmask] %>
<% elsif interface[:family] == "inet6" -%>
<% if interface[:family] == "inet6" -%>
autoconf 0
<% end -%>
+<% if interface[:bond] -%>
+ bond-mode <%= interface[:bond][:mode] || "active-backup" %>
+ bond-slaves none
+ bond-primary <%= interface[:bond][:slaves].first %>
+ bond-miimon <%= interface[:bond][:miimon] || 100 %>
+ bond-downdelay <%= interface[:bond][:downdelay] || 200 %>
+ bond-updelay <%= interface[:bond][:updelay] || 200 %>
+<% end -%>
+<% end -%>
<% end -%>
-auto lo <%= node[:networking][:interfaces].collect { |n,i| i[:interface] }.sort.uniq.join(" ") %>
+auto lo <%= node[:networking][:interfaces].collect { |n,i| i[:interface] }.compact.sort.uniq.join(" ") %>