diff --git a/ansible/configure-server.yml b/ansible/configure-server.yml index d9394c2..d65947c 100644 --- a/ansible/configure-server.yml +++ b/ansible/configure-server.yml @@ -180,7 +180,49 @@ mode: 0640 notify: restart frr + - name: Copy systemd netdevs + ansible.builtin.template: + src: files/{{item}}.netdev + dest: /etc/systemd/network/ + owner: root + group: root + mode: 0644 + with_items: + - bgp + - bgp-backup + register: netdevs + - name: Copy systemd bgp network + ansible.builtin.template: + src: files/{{item}}.network + dest: /etc/systemd/network/ + owner: root + group: root + mode: 0644 + with_items: + - bgp + - bgp-backup + register: bgpnetworks + + - name: Copy systemd bgp-backup network + ansible.builtin.template: + src: files/bgp-backup.network + dest: /etc/systemd/network/ + owner: root + group: root + mode: 0644 + register: networks + + - name: Reload systemd-networkd + shell: networkctl reload + when: netdevs.changed or networks.changed or bgpnetworks.changed + + + - name: Enable FRR + service: + name: frr + enabled: yes + state: started handlers: - name: restart frr diff --git a/ansible/files/bgp-backup.netdev b/ansible/files/bgp-backup.netdev new file mode 100644 index 0000000..0faae4c --- /dev/null +++ b/ansible/files/bgp-backup.netdev @@ -0,0 +1,3 @@ +[NetDev] +Name=bgp-backup +Kind=dummy diff --git a/ansible/files/bgp-backup.network b/ansible/files/bgp-backup.network new file mode 100644 index 0000000..f3b98cd --- /dev/null +++ b/ansible/files/bgp-backup.network @@ -0,0 +1,9 @@ +[Match] +Name=bgp-backup + +[Network] +{% for host in groups['all'] -%} +{%- if host != inventory_hostname -%} +Address={{ hostvars[host]['bgp_ipv6'] }} +{% endif -%} +{% endfor %} diff --git a/ansible/files/bgp.netdev b/ansible/files/bgp.netdev new file mode 100644 index 0000000..b57f457 --- /dev/null +++ b/ansible/files/bgp.netdev @@ -0,0 +1,3 @@ +[NetDev] +Name=bgp +Kind=dummy diff --git a/ansible/files/bgp.network b/ansible/files/bgp.network new file mode 100644 index 0000000..836a89a --- /dev/null +++ b/ansible/files/bgp.network @@ -0,0 +1,5 @@ +[Match] +Name=bgp + +[Network] +Address={{bgp_ipv6}} diff --git a/ansible/files/frr.conf.j2 b/ansible/files/frr.conf.j2 index a1913e5..a75ddc1 100644 --- a/ansible/files/frr.conf.j2 +++ b/ansible/files/frr.conf.j2 @@ -15,22 +15,23 @@ router bgp {{ bgp_asn }} neighbor {{ bgp_router_ipv6 }} peer-group pg-leaf ! address-family ipv4 unicast - redistribute connected route-map map-bgp-iface + redistribute connected route-map map-bgp neighbor pg-leaf soft-reconfiguration inbound exit-address-family ! address-family ipv6 unicast - redistribute kernel - redistribute connected route-map map-bgp-iface + redistribute connected route-map map-bgp neighbor pg-leaf activate neighbor pg-leaf soft-reconfiguration inbound - neighbor pg-leaf route-map map-bgp-iface out + neighbor pg-leaf route-map map-bgp out exit-address-family exit ! -route-map map-bgp-iface permit 10 - match interface lo -exit +route-map map-bgp permit 10 + match interface bgp +route-map map-bgp permit 20 + match interface bgp-backup + set as-path prepend {{ bgp_asn }} {{ bgp_asn }} {{ bgp_asn }} ! end diff --git a/ansible/files/interface b/ansible/files/interface new file mode 100644 index 0000000..e69de29