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

162 lines
4.3 KiB
Text
Raw Normal View History

2022-12-21 21:01:47 +01:00
{{ ansible_managed | comment }}
2023-11-07 04:11:28 +01:00
{% macro import_export(obj, ipv4) %}
{{ obj.import | default([]) | bird_import(ipv4) }}
{% if obj.limits.import is defined %}
import limit {{ obj.limits.import }};
{% endif %}
{{ obj.export | default([]) | bird_export(ipv4) }}
{% if obj.limits.export is defined %}
export limit {{ obj.limits.export }};
{% endif %}
{% endmacro %}
log syslog all;
router id {{ bird__router_id }};
2023-11-07 04:11:28 +01:00
{% for table in bird__tables %}
{% for version in ["ipv4", "ipv6"] %}
{{ version }} table {{ table | bird_name(version == "ipv4") }};
{% endfor %}
{% endfor %}
protocol device {
scan time 10;
}
2023-09-16 01:24:01 +02:00
{% for name, kernel in bird__kernel.items() %}
{% for version in ["ipv4", "ipv6"] %}
{% set is_ipv4 = version == "ipv4" %}
protocol kernel {{ name | bird_name(is_ipv4) }} {
2023-09-16 01:24:01 +02:00
{% 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 }} {
2023-11-07 04:11:28 +01:00
{% if kernel.table is defined %}
table {{ kernel.table | bird_name(is_ipv4) }};
2023-09-16 01:24:01 +02:00
{% endif %}
{{ import_export(kernel, is_ipv4) | indent(8) }}
2023-09-16 01:24:01 +02:00
};
2022-09-04 07:40:51 +02:00
}
2023-09-16 01:24:01 +02:00
{% endfor %}
{% endfor %}
2022-09-04 07:40:51 +02:00
2023-11-07 04:11:28 +01:00
{% for name, pipe in bird__pipes.items() %}
{% for version in ["ipv4", "ipv6"] %}
{% set is_ipv4 = version == "ipv4" %}
protocol pipe {{ name | bird_name(is_ipv4) }} {
table {{ pipe.table | bird_name(is_ipv4) }};
peer table {{ pipe.peer_table | default("master") | bird_name(is_ipv4) }};
{{ import_export(kernel, is_ipv4) | indent(4) }}
2023-11-07 04:11:28 +01:00
}
{% endfor %}
{% endfor %}
2023-09-16 01:24:01 +02:00
{% if bird__ospf is defined %}
{% for version in ["ipv4", "ipv6"] %}
{% set is_ipv4 = version == "ipv4" %}
{% set ospf_version = "v2" if is_ipv4 else "v3" %}
protocol ospf {{ ospf_version }} {{ "ospf" | bird_name(is_ipv4) }} {
2023-09-16 01:24:01 +02:00
{{ version }} {
2023-11-07 04:11:28 +01:00
{% if bird__ospf.table is defined %}
table {{ bird__ospf.table | bird_name(is_ipv4) }};
2023-09-16 01:24:01 +02:00
{% endif %}
{{ import_export(bird__ospf, is_ipv4) | indent(8) }}
2023-09-16 01:24:01 +02:00
};
{% 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 %}
};
2023-09-16 01:24:01 +02:00
{% endfor %}
}
2023-09-16 01:24:01 +02:00
{% endfor %}
{% endif %}
2023-09-16 01:24:01 +02:00
{% for name, bgp in bird__bgp.items() %}
{% for version in ["ipv4", "ipv6"] %}
{% set is_ipv4 = version == "ipv4" %}
protocol bgp {{ name | bird_name(is_ipv4) }} {
2023-09-16 01:24:01 +02:00
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 }};
2023-11-04 21:43:32 +01:00
{% if bgp.rr_cluster_client is defined %}
rr client;
rr cluster id {{ bgp.rr_cluster_client }};
{% endif %}
2023-09-16 01:24:01 +02:00
{{ version }} {
2023-11-07 04:11:28 +01:00
{% if bgp.table is defined %}
table {{ bgp.table | bird_name(is_ipv4) }};
2023-09-16 01:24:01 +02:00
{% endif %}
2023-11-07 04:11:28 +01:00
{% if bgp.next_hop_self is defined %}
next hop self;
2023-09-16 01:24:01 +02:00
{% endif %}
{{ import_export(bgp, is_ipv4) | indent(8) }}
};
}
2023-09-16 01:24:01 +02:00
{% endfor %}
{% endfor %}
2023-09-18 17:15:57 +02:00
{% 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 %}
2023-09-16 01:24:01 +02:00
{# {% if bird__static_unreachable | ansible.utils.ipv4 %}
2022-12-21 16:39:28 +01:00
protocol static unreachable4 {
2022-12-21 19:53:40 +01:00
ipv4 {
2022-12-22 11:00:37 +01:00
import all;
2022-12-21 19:53:40 +01:00
};
2022-12-21 16:39:28 +01:00
{% for route in bird__static_unreachable | ansible.utils.ipv4 %}
2022-12-21 19:53:40 +01:00
route {{ route }} unreachable;
2022-12-21 16:39:28 +01:00
{% endfor %}
}
{% endif %}
{% if bird__static_unreachable | ansible.utils.ipv6 %}
protocol static unreachable6 {
2022-12-21 19:53:40 +01:00
ipv6 {
2022-12-22 11:00:37 +01:00
import all;
2022-12-21 19:53:40 +01:00
};
2022-12-21 16:39:28 +01:00
{% for route in bird__static_unreachable | ansible.utils.ipv6 %}
2022-12-21 19:53:40 +01:00
route {{ route }} unreachable;
2022-12-21 16:39:28 +01:00
{% endfor %}
}
2023-09-16 01:24:01 +02:00
{% endif %} #}