ansible/roles/bird/templates/bird.conf.j2

160 lines
4.1 KiB
Django/Jinja

{{ ansible_managed | comment }}
log syslog all;
router id {{ bird__router_id }};
protocol device {
scan time 10;
}
{% for name, kernel in bird__kernel.items() %}
{% for version in ["ipv4", "ipv6"] %}
{% set ipv4 = version == "ipv4" %}
protocol kernel {{ name | bird_name(ipv4) }} {
{% if kernel.kernel is defined %}
kernel table {{ kernel.kernel }};
{% endif %}
{% if kernel.learn | default(False) %}
learn;
{% endif %}
{% if kernel.persist | default(False) %}
persist;
{% endif %}
{{ version }} {
{{ kernel.import
| default([])
| bird_import(ipv4)
| indent(8) }}
{% if kernel.limits.import is defined %}
import limit {{ kernel.limits.import }};
{% endif %}
{{ kernel.export
| default([])
| bird_export(ipv4)
| indent(8) }}
{% if kernel.limits.export is defined %}
export limit {{ kernel.limits.export }};
{% endif %}
};
}
{% endfor %}
{% endfor %}
{% if bird__ospf is defined %}
{% for version in ["ipv4", "ipv6"] %}
{% set ipv4 = version == "ipv4" %}
{% set ospf_version = "v2" if ipv4 else "v3" %}
protocol ospf {{ ospf_version }} {{ "ospf" | bird_name(ipv4) }} {
{{ version }} {
{{ bird__ospf.import
| default([])
| bird_import(ipv4)
| indent(8) }}
{% if bird__ospf.limits.import is defined %}
import limit {{ bird__ospf.limits.import }};
{% endif %}
{{ bird__ospf.export
| default([])
| bird_export(ipv4)
| indent(8) }}
{% if bird__ospf.limits.export is defined %}
export limit {{ bird__ospf.limits.export }};
{% endif %}
};
{% for id, area in bird__ospf.areas.items() %}
area {{ id }} {
{% for iface in area.broadcast | default([]) %}
interface {{ iface | enquote }} {
type broadcast;
hello 2;
retransmit 5;
wait 10;
dead 20;
};
{% endfor %}
{% for iface in area.stub | default([]) %}
interface {{ iface | enquote }} { stub; };
{% endfor %}
};
{% endfor %}
}
{% endfor %}
{% endif %}
{% for name, bgp in bird__bgp.items() %}
{% for version in ["ipv4", "ipv6"] %}
{% set ipv4 = version == "ipv4" %}
protocol bgp {{ name | bird_name(ipv4) }} {
local {{ bgp.local.address
| ansible.utils.ipaddr(version)
| first }} as {{ bgp.local.as }};
neighbor {{ bgp.neighbor.address
| ansible.utils.ipaddr(version)
| first }} as {{ bgp.neighbor.as }};
{% if bgp.rr_cluster_client is defined %}
rr client;
rr cluster id {{ bgp.rr_cluster_client }};
{% endif %}
{{ version }} {
{{ bgp.import
| default([])
| bird_import(ipv4)
| indent(8) }}
{% if bgp.limits.import is defined %}
import limit {{ bgp.limits.import }};
{% endif %}
{{ bgp.export
| default([])
| bird_export(ipv4)
| indent(8) }}
{% if bgp.limits.export is defined %}
export limit {{ bgp.limits.export }};
{% endif %}
};
}
{% endfor %}
{% endfor %}
{% if bird__radv is defined %}
protocol radv {
{% set interfaces = bird__radv.interfaces | default({}) %}
{% for iface, radv in interfaces.items() %}
interface {{ iface | enquote }} {
max ra interval {{ radv.max_interval
| default(bird__radv_max_interval) }};
{% for prefix in radv.prefixes | default([]) %}
prefix {{ prefix }};
{% endfor %}
{% for domain in radv.domain_search | default([]) %}
dnssl {{ domain | enquote }};
{% endfor %}
};
{% endfor %}
{% for addr in bird__radv.rdnss | default([]) %}
rdnss {{ addr }};
{% endfor %}
}
{% endif %}
{# {% if bird__static_unreachable | ansible.utils.ipv4 %}
protocol static unreachable4 {
ipv4 {
import all;
};
{% for route in bird__static_unreachable | ansible.utils.ipv4 %}
route {{ route }} unreachable;
{% endfor %}
}
{% endif %}
{% if bird__static_unreachable | ansible.utils.ipv6 %}
protocol static unreachable6 {
ipv6 {
import all;
};
{% for route in bird__static_unreachable | ansible.utils.ipv6 %}
route {{ route }} unreachable;
{% endfor %}
}
{% endif %} #}