{% for vname,vdata in vrfs.items() %}

{#
  Create interface list for the vrf
#}
{% set vrf_if_list = [] %}
{% for l in interfaces|default([]) %}
{%   if l.vrf is defined and l.vrf == vname %}
{{ vrf_if_list.append(l.ifname) }}
{%   endif %}
{% endfor %}

/ip/vrf/add place-before=0 name={{ vname }} interfaces={{ vrf_if_list|join(',') }}

{% endfor %}