X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/faf8ae12e85eabb050b0f5eceb2cb67ad1de5261..a12bd631f0eed60f140864d7fbc1b61b54d17b43:/cookbooks/networking/templates/default/interfaces.erb?ds=sidebyside diff --git a/cookbooks/networking/templates/default/interfaces.erb b/cookbooks/networking/templates/default/interfaces.erb index 89fc316eb..d0d4dd7c8 100644 --- a/cookbooks/networking/templates/default/interfaces.erb +++ b/cookbooks/networking/templates/default/interfaces.erb @@ -2,34 +2,62 @@ iface lo inet loopback <% node[:networking][:interfaces].each do |name,interface| -%> +<% if interface[:interface] -%> +<% if interface[:bond] -%> +<% interface[:bond][:slaves].each do |slave| -%> + +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[:interface] =~ /\.\d+$/ -%> + vlan-raw-device <%= interface[:interface].split(".").first %> +<% end -%> + address <%= interface[:address] %> <% if interface[:family] == "inet" -%> - netmask <%= interface[:netmask] %> + netmask <%= interface[:netmask] %> <% elsif interface[:family] == "inet6" -%> - netmask <%= interface[:prefix] %> + netmask <%= interface[:prefix] %> <% end -%> <% if interface[:hwaddress] -%> hwaddress <%= interface[:hwaddress] %> <% end -%> <% if interface[:gateway] -%> <% if interface[:network].include?(interface[:gateway]) or IPAddr.new("fe80::/64").include?(interface[:gateway]) -%> - gateway <%= interface[:gateway] %> - metric <%= interface[:metric] %> + gateway <%= interface[:gateway] %> + metric <%= interface[:metric] %> <% else -%> - post-up /sbin/ip -f <%= interface[:family] %> route add <%= interface[:gateway] %> dev <%= interface[:interface] %> - post-up /sbin/ip -f <%= interface[:family] %> route add default metric <%= interface[:metric] %> via <%= interface[:gateway] %> - pre-down /sbin/ip -f <%= interface[:family] %> route del default metric <%= interface[:metric] %> via <%= interface[:gateway] %> - pre-down /sbin/ip -f <%= interface[:family] %> route del <%= interface[:gateway] %> dev <%= interface[:interface] %> + post-up /sbin/ip -f <%= interface[:family] %> route add <%= interface[:gateway] %> dev <%= interface[:interface] %> + post-up /sbin/ip -f <%= interface[:family] %> route add default metric <%= interface[:metric] %> via <%= interface[:gateway] %> + pre-down /sbin/ip -f <%= interface[:family] %> route del default metric <%= interface[:metric] %> via <%= interface[:gateway] %> + pre-down /sbin/ip -f <%= interface[:family] %> route del <%= interface[:gateway] %> dev <%= interface[:interface] %> <% end -%> <% end -%> <% if interface[:mtu] -%> - mtu <%= interface[:mtu] %> + mtu <%= interface[:mtu] %> <% end -%> <% if interface[:family] == "inet6" -%> - autoconf 0 + 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 %> +<% if interface[:bond][:xmithashpolicy] -%> + bond_xmit_hash_policy <%= interface[:bond][:xmithashpolicy] %> +<% end -%> +<% if interface[:bond][:lacprate] -%> + bond-lacp-rate <%= interface[:bond][:lacprate] %> +<% end -%> + 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(" ") %>