bird/README.md
2024-05-16 17:58:49 +03:00

173 lines
4.9 KiB
Markdown

# Idempotent ansible role for Bird
Tips: Use with network role for loopback/dummy interface configuraton
## Supported OS
- AlmaLinux 8/9
- Rocky Linux 8/9
- CentOS 7
- Debian 11/12
- Ubuntu 20.04/22.04/24.04
## Bird config examples
<details>
<summary>Using template config</summary>
# Set routing interface
bird_interface: "eth1"
bird:
bgp:
common:
storage04.s3.msk2.example.com:
routerid: 10.101.42.14
storage05.s3.msk2.example.com:
routerid: 10.101.42.15
storage06.s3.msk2.example.com:
routerid: 10.101.42.16
storage07.s3.msk2.example.com:
routerid: 10.101.42.17
static:
- name: STATIC1
networks:
storage04.s3.msk2.example.com:
- ip: "10.110.42.1/32"
bgp_local_pref: "100"
interface: "{{ bird_interface }}"
- ip: "10.110.42.21/32"
bgp_local_pref: "100"
interface: "{{ bird_interface }}"
storage05.s3.msk2.example.com:
- ip: "10.110.42.1/32"
bgp_local_pref: "100"
interface: "{{ bird_interface }}"
- ip: "10.110.42.21/32"
bgp_local_pref: "100"
interface: "{{ bird_interface }}"
storage06.s3.msk2.example.com:
- ip: "10.110.42.1/32"
bgp_local_pref: "100"
interface: "{{ bird_interface }}"
- ip: "10.110.42.21/32"
bgp_local_pref: "100"
interface: "{{ bird_interface }}"
storage07.s3.msk2.example.com:
- ip: "10.110.42.1/32"
bgp_local_pref: "100"
interface: "{{ bird_interface }}"
- ip: "10.110.42.21/32"
bgp_local_pref: "100"
interface: "{{ bird_interface }}"
bgp:
- name: SW06
remote_asnum: 4200200000
local_asnum: 4200200000
confederation: 209684
remote_addr: "10.127.2.6"
export:
- STATIC1
- name: SW10
remote_asnum: 4200200000
local_asnum: 4200200000
confederation: 209684
remote_addr: "10.127.2.10"
export:
- STATIC1
</details>
<details>
<summary>Complete config override</summary>
bird:
bgp_asnum: 4200200000
bgp_mesh:
controller1.example.com:
routerid: "10.180.0.101"
bgp:
- "10.180.0.101"
- "192.168.255.101"
controller2.example.com:
routerid: "10.180.0.102"
bgp:
- "10.180.0.102"
- "192.168.255.102"
controller3.example.com:
routerid: "10.180.0.103"
bgp:
- "10.180.0.103"
- "192.168.255.103"
compute1.example.com:
routerid: "10.180.0.104"
bgp:
- "10.180.0.104"
- "192.168.255.104"
compute2.example.com:
routerid: "10.180.0.105"
bgp:
- "10.180.0.105"
- "192.168.255.105"
bird_config_override: |
log syslog all;
router id {{ bird.bgp_mesh[inventory_hostname].bgp[0] }};
filter bgp_mesh_export {
if net ~ [192.168.0.101/32] then accept;
if net ~ [192.168.0.102/32] then accept;
if net ~ [192.168.0.103/32] then accept;
if net ~ [192.168.0.104/32] then accept;
if net ~ [192.168.0.105/32] then accept;
reject;
}
filter bgp_mesh_import {
if net ~ [192.168.0.101/32] then accept;
if net ~ [192.168.0.102/32] then accept;
if net ~ [192.168.0.103/32] then accept;
if net ~ [192.168.0.104/32] then accept;
if net ~ [192.168.0.105/32] then accept;
reject;
}
protocol device {
}
protocol direct {
ipv4;
ipv6;
}
protocol kernel KERNEL4 {
merge paths yes;
learn;
ipv4 {
export all;
};
}
protocol kernel KERNEL6 {
ipv6 {
export all;
};
}
{% for host in bird.bgp_mesh %}
{% for protocol_bgp in bird.bgp_mesh[host].bgp %}
{% if inventory_hostname not in host %}
protocol bgp {{ host.split(".")[0] }}_{{ loop.index * 100 }} {
password "3472e7d08e4aca276d72b5165adfc189";
source address {{ bird.bgp_mesh[inventory_hostname].bgp[loop.index0] }};
local as {{ bird.bgp_asnum }};
neighbor {{ protocol_bgp }} as {{ bird.bgp_asnum }};
hold time 10;
ipv4 {
import filter bgp_mesh_import;
export filter bgp_mesh_export;
};
default bgp_local_pref {{ 300 - (loop.index * 100) }};
}
{% endif %}
{% endfor %}
{% endfor %}
</details>