# File managed by puppet

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

<% if auto.any? %>
auto <%= auto.join(" ") %>
<% end %>

<% mappings.sort.each do |name_and_options| %>
mapping <%= name_and_options[0] %>
  script <%= name_and_options[1]["script"] %>
  <%- name_and_options[1]["maps"].each do |value| -%>
  map <%= value %>
  <%- end -%>
<% end %>

<% interfaces.sort.each do |name_and_options| %>
iface <%= name_and_options[0] %> inet <%= name_and_options[1]["method"] %>
  <%- name_and_options[1].reject { |k, v| k == "method" }.sort.each do |option| -%>
  <%= option[0] %> <%= option[1] %>
  <%- end -%>
<% end %>

# File managed by puppet

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

<% if auto.any? %>
auto <%= auto.join(" ") %>
<% end %>

<% mappings.sort.each do |name_and_options| %>
mapping <%= name_and_options[0] %>
  script <%= name_and_options[1]["script"] %>
  <%- name_and_options[1]["maps"].each do |value| -%>
  map <%= value %>
  <%- end -%>
<% end %>

<% interfaces.sort.each do |name_and_options| %>
iface <%= name_and_options[0] %> inet <%= name_and_options[1]["method"] %>
  <%- name_and_options[1].reject { |k, v| k == "method" }.sort.each do |option| -%>
  <%- if option[1].is_a? Array -%>
  <%- option[1].each do |value| -%>
  <%= option[0] %> <%= value %>
  <%- end -%>
  <%- else -%>
  <%= option[0] %> <%= option[1] %>
  <%- end -%>
  <%- end -%>
<% end %>

Handle multiple options with same name correctly
Handle multiple options with same name correctly

If the interface should have several entries with the same name,
only the last one in the hash made it into the config file. This
change enables the value to be an array which is then expanded
to multiple lines. Now one can write
'up' => [ 'ip route add 10.0.0.0/8 via 10.0.0.1', 'ip route add 192.168.0.0/16 via 10.0.0.1' ]
and have multiple up commands in the interface.
