2024-05-16 14:58:49 +00:00
|
|
|
# Idempotent ansible role for Bird
|
2024-05-11 00:12:41 +00:00
|
|
|
Tips: Use with network role for loopback/dummy interface configuraton
|
2021-10-26 15:53:11 +00:00
|
|
|
|
2024-05-11 00:12:41 +00:00
|
|
|
## Supported OS
|
2024-05-11 00:10:14 +00:00
|
|
|
- AlmaLinux 8/9
|
|
|
|
- Rocky Linux 8/9
|
|
|
|
- CentOS 7
|
|
|
|
- Debian 11/12
|
2024-05-11 01:00:36 +00:00
|
|
|
- Ubuntu 20.04/22.04/24.04
|
2024-05-11 00:10:14 +00:00
|
|
|
|
2024-05-11 00:12:41 +00:00
|
|
|
## Bird config examples
|
2024-05-11 00:10:14 +00:00
|
|
|
<details>
|
|
|
|
<summary>Using template config</summary>
|
2021-10-25 09:56:39 +00:00
|
|
|
|
2021-10-27 11:35:53 +00:00
|
|
|
# Set routing interface
|
|
|
|
bird_interface: "eth1"
|
2021-10-25 09:56:39 +00:00
|
|
|
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:
|
2021-10-26 21:33:38 +00:00
|
|
|
- ip: "10.110.42.1/32"
|
2021-10-25 09:56:39 +00:00
|
|
|
bgp_local_pref: "100"
|
2021-10-26 21:47:25 +00:00
|
|
|
interface: "{{ bird_interface }}"
|
2021-10-26 21:33:38 +00:00
|
|
|
- ip: "10.110.42.21/32"
|
2021-10-25 09:56:39 +00:00
|
|
|
bgp_local_pref: "100"
|
2021-10-26 21:47:25 +00:00
|
|
|
interface: "{{ bird_interface }}"
|
2021-10-25 09:56:39 +00:00
|
|
|
storage05.s3.msk2.example.com:
|
2021-10-26 21:33:38 +00:00
|
|
|
- ip: "10.110.42.1/32"
|
2021-10-25 09:56:39 +00:00
|
|
|
bgp_local_pref: "100"
|
2021-10-26 21:47:25 +00:00
|
|
|
interface: "{{ bird_interface }}"
|
2021-10-26 21:33:38 +00:00
|
|
|
- ip: "10.110.42.21/32"
|
2021-10-25 09:56:39 +00:00
|
|
|
bgp_local_pref: "100"
|
2021-10-26 21:47:25 +00:00
|
|
|
interface: "{{ bird_interface }}"
|
2021-10-25 09:56:39 +00:00
|
|
|
storage06.s3.msk2.example.com:
|
2021-10-26 21:33:38 +00:00
|
|
|
- ip: "10.110.42.1/32"
|
2021-10-25 09:56:39 +00:00
|
|
|
bgp_local_pref: "100"
|
2021-10-26 21:47:25 +00:00
|
|
|
interface: "{{ bird_interface }}"
|
2021-10-26 21:33:38 +00:00
|
|
|
- ip: "10.110.42.21/32"
|
2021-10-25 09:56:39 +00:00
|
|
|
bgp_local_pref: "100"
|
2021-10-26 21:47:25 +00:00
|
|
|
interface: "{{ bird_interface }}"
|
2021-10-25 09:56:39 +00:00
|
|
|
storage07.s3.msk2.example.com:
|
2021-10-26 21:33:38 +00:00
|
|
|
- ip: "10.110.42.1/32"
|
2021-10-25 09:56:39 +00:00
|
|
|
bgp_local_pref: "100"
|
2021-10-26 21:47:25 +00:00
|
|
|
interface: "{{ bird_interface }}"
|
2021-10-26 21:33:38 +00:00
|
|
|
- ip: "10.110.42.21/32"
|
2021-10-25 09:56:39 +00:00
|
|
|
bgp_local_pref: "100"
|
2021-10-26 21:47:25 +00:00
|
|
|
interface: "{{ bird_interface }}"
|
2021-10-25 09:56:39 +00:00
|
|
|
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
|
2024-05-11 00:10:14 +00:00
|
|
|
|
|
|
|
</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>
|