{% if 'ipv6' in isis.af %}
ipv6 unicast-routing
{% endif %}
!
router isis Gandalf
  log-adjacency-changes
  is-hostname {{ inventory_hostname }}
  is-type {{ isis.type }}
{% if isis.net is defined %}
  net {{ isis.net }}
{% elif isis.area is defined %}
  net {{ "%s.0000.0000.%04d.00" % (isis.area,id) }}
{% endif %}
{% if isis.af.ipv4 is defined %}
  address-family ipv4 unicast
{% endif %}
{% if isis.af.ipv6 is defined %}
  address-family ipv6 unicast
    multi-topology
{% endif %}
!
interface Loopback0
  isis enable Gandalf
!
{% for l in interfaces|default([]) if 'isis' in l %}
interface {{ l.ifname }}
! {{ l.name|default("") }}
  isis enable Gandalf
{%   if l.isis.network_type is defined %}
  isis network {{ l.isis.network_type }}
{%   endif %}
{%   if l.isis.cost is defined or l.isis.metric is defined %}
  isis metric {{ l.isis.metric|default(l.isis.cost) }}
{%     if 'ipv6' in isis.af and 'ipv6' in l %}
  isis ipv6 metric {{ l.isis.metric|default(l.isis.cost) }}
{%     endif %}}
{%   endif %}
{%   if l.isis.bfd.ipv4|default(False) %}
  isis bfd
{%   endif %}
{%   if l.isis.bfd.ipv6|default(False) %}
! BFD is not supported for IPv6 ISIS
{%   endif %}
{%   if l.isis.passive %}
  isis passive
{%   endif %}
!
{% endfor %}
