auto lo
iface lo inet loopback

{% for iface in interfaces %}
auto {{ iface.name }}
iface {{ iface.name }} inet static
{% for address in iface.ip_addresses %}
    address {{ address.address }}
{% endfor %}
{% if iface.custom_fields.gateway %}
    gateway {{ iface.custom_fields.gateway.address | ipaddr('address') }}
{% endif %}

{% endfor %}