{% set pid = ospf.process|default(0) %}
updates:
- path: network-instance[name=default]
  val:
   router-id: {{ ospf.router_id }}
   protocols:
    ospf:
     instance:
     - name: "{{ pid }}"
       version: ospf-v2
       admin-state: enable
       max-ecmp-paths: 64
{%     if ospf.reference_bandwidth is defined %}
       reference-bandwidth: {{ ospf.reference_bandwidth * 1000 }} # in kbps
{%     endif %}
       area:
       - area-id: {{ ospf.area }}
         interface:
         - interface-name: system0.0
           passive: True
{%     for l in interfaces|default([]) %}
{%     if 'ospf' not in l %}
       # OSPF not configured on external interface {{ l.ifname }}
       - area-id: {{ ospf.area }}
         interface:
         - interface-name: {{ l.ifname }}.0
           admin-state: disable
           _annotate_admin-state: "Disabled: external interface"
{%     else %}
       - area-id: {{ l.ospf.area }}
         interface:
         - interface-name: {{ l.ifname }}.0
           passive: {{ ospf.passive | default(False) }}
{%         if l.ospf.network_type|default("") in ["broadcast","point-to-point"] %}
           interface-type: "{{ l.ospf.network_type }}"
{%         endif %}
           failure-detection:
            enable-bfd: {{ l.ospf.bfd|default(False) }}
{%         if l.ospf.cost is defined %}
           metric: {{ l.ospf.cost }}
{%         endif %}
{%     endif %}
{%     endfor %}
