mirror of
https://gitea.0xace.cc/ansible-galaxy/bird.git
synced 2025-01-18 12:02:22 +00:00
rewrite bird
This commit is contained in:
parent
0bdd5f6950
commit
f0e516002f
54
README.md
54
README.md
@ -1,17 +1,9 @@
|
||||
Setup BIRD with BGP on loopback or dummy interface
|
||||
|
||||
For RHEL8 use 'nm' for NetworkManager and dummy iface for BGP IPs
|
||||
For RHEL7 use 'ns' for network-scripts and lo iface for BGP IPs
|
||||
|
||||
network: "nm"
|
||||
network_nm_iface: "dummy0"
|
||||
|
||||
Use 0 for MTU auto
|
||||
|
||||
network_nm_iface_mtu: 0
|
||||
Setup BIRD with BGP
|
||||
Use with network role for loopback/dummy interface configuraton
|
||||
|
||||
BIRD config example:
|
||||
|
||||
bird_interface: "dummy0"
|
||||
bird:
|
||||
bgp:
|
||||
common:
|
||||
@ -27,41 +19,33 @@ BIRD config example:
|
||||
- name: STATIC1
|
||||
networks:
|
||||
storage04.s3.msk2.example.com:
|
||||
- ip: "10.110.42.1"
|
||||
mask: "255.255.255.255"
|
||||
mask_dash: "32"
|
||||
- ip: "10.110.42.1/32"
|
||||
bgp_local_pref: "100"
|
||||
- ip: "10.110.42.21"
|
||||
mask: "255.255.255.255"
|
||||
mask_dash: "32"
|
||||
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"
|
||||
mask: "255.255.255.255"
|
||||
mask_dash: "32"
|
||||
- ip: "10.110.42.1/32"
|
||||
bgp_local_pref: "100"
|
||||
- ip: "10.110.42.21"
|
||||
mask: "255.255.255.255"
|
||||
mask_dash: "32"
|
||||
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"
|
||||
mask: "255.255.255.255"
|
||||
mask_dash: "32"
|
||||
- ip: "10.110.42.1/32"
|
||||
bgp_local_pref: "100"
|
||||
- ip: "10.110.42.21"
|
||||
mask: "255.255.255.255"
|
||||
mask_dash: "32"
|
||||
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"
|
||||
mask: "255.255.255.255"
|
||||
mask_dash: "32"
|
||||
- ip: "10.110.42.1/32"
|
||||
bgp_local_pref: "100"
|
||||
- ip: "10.110.42.21"
|
||||
mask: "255.255.255.255"
|
||||
mask_dash: "32"
|
||||
interface: "{{ bird_interface }}"
|
||||
- ip: "10.110.42.21/32"
|
||||
bgp_local_pref: "100"
|
||||
interface: "{{ bird_interface }}"
|
||||
bgp:
|
||||
- name: SW06
|
||||
remote_asnum: 4200200000
|
||||
|
@ -1,7 +0,0 @@
|
||||
# use 'nm' for NetworkManager and dummy iface for BGP IPs
|
||||
# use 'ns' for network-scripts and lo iface for BGP IPs
|
||||
network: "nm"
|
||||
network_nm_iface: "dummy0"
|
||||
|
||||
# 0 for MTU auto
|
||||
network_nm_iface_mtu: 0
|
@ -15,5 +15,5 @@
|
||||
shell: |
|
||||
ifdown lo ; ifup lo
|
||||
|
||||
- name: Reload dummy interface
|
||||
command: nmcli conn up {{ network_nm_iface }}
|
||||
- name: Reload dummy interface with nmcli
|
||||
command: nmcli conn up {{ bird_network_nm_iface }}
|
||||
|
2
meta/.galaxy_install_info
Normal file
2
meta/.galaxy_install_info
Normal file
@ -0,0 +1,2 @@
|
||||
install_date: 'Tue 26 Oct 2021 04:12:10 PM '
|
||||
version: ''
|
@ -4,19 +4,12 @@
|
||||
name: bird2
|
||||
state: present
|
||||
|
||||
- name: Update ifcfg-lo config
|
||||
template:
|
||||
src: ifcfg-lo.j2
|
||||
dest: /etc/sysconfig/network-scripts/ifcfg-lo
|
||||
notify:
|
||||
- Restart loopback
|
||||
|
||||
- name: Add BIRD config
|
||||
template:
|
||||
src: bird.conf.j2
|
||||
dest: /etc/bird.conf
|
||||
notify:
|
||||
- Reload bird
|
||||
- Reload BIRD
|
||||
|
||||
- name: Start BIRD service
|
||||
systemd:
|
||||
@ -24,3 +17,4 @@
|
||||
state: started
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
|
||||
|
@ -4,44 +4,6 @@
|
||||
name: bird
|
||||
state: present
|
||||
|
||||
- block:
|
||||
- name: Install network scripts
|
||||
package:
|
||||
name: network-scripts
|
||||
state: present
|
||||
|
||||
- name: Update ifcfg-lo config
|
||||
template:
|
||||
src: ifcfg-lo.j2
|
||||
dest: /etc/sysconfig/network-scripts/ifcfg-lo
|
||||
notify:
|
||||
- Restart loopback
|
||||
when: network == 'ns'
|
||||
|
||||
|
||||
- block:
|
||||
- name: BGP IPs string for nmcli
|
||||
set_fact:
|
||||
ips: |-
|
||||
{%- set ips_list = [] %}
|
||||
{%- for protocol_static in bird.bgp.static %}
|
||||
{%- for network in protocol_static['networks'][ansible_fqdn] %}
|
||||
{{ ips_list.append(network['ip'] + '/' + network['mask_dash']) }}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
{{ ips_list | join(', ') }}
|
||||
|
||||
- name: Add dummy interface and add IPs
|
||||
community.general.nmcli:
|
||||
type: dummy
|
||||
conn_name: "{{ network_nm_iface }}"
|
||||
ip4: "{{ ips }}"
|
||||
mtu: "{{ network_nm_iface_mtu }}"
|
||||
state: present
|
||||
notify:
|
||||
- Reload dummy interface
|
||||
when: network == 'nm'
|
||||
|
||||
- name: Add BIRD config
|
||||
template:
|
||||
src: bird.conf.j2
|
||||
|
@ -24,7 +24,7 @@ protocol kernel KERNEL6 {
|
||||
protocol static {{ protocol_static.name }} {
|
||||
ipv4;
|
||||
{% for network in protocol_static['networks'][inventory_hostname] %}
|
||||
route {{ network.ip }}/{{ network.mask_dash }} via "lo" { bgp_local_pref = {{ network.bgp_local_pref }}; };
|
||||
route {{ network.ip }} via "{{ network.interface }}" { bgp_local_pref = {{ network.bgp_local_pref }}; };
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
|
@ -1,15 +0,0 @@
|
||||
DEVICE=lo
|
||||
IPADDR=127.0.0.1
|
||||
NETMASK=255.0.0.0
|
||||
NETWORK=127.0.0.0
|
||||
# If you're having problems with gated making 127.0.0.0/8 a martian,
|
||||
# you can change this to something else (255.255.255.255, for example)
|
||||
BROADCAST=127.255.255.255
|
||||
{% for protocol_static in bird.bgp.static %}
|
||||
{% for network in protocol_static['networks'][ansible_fqdn] %}
|
||||
IPADDR{{ loop.index }}={{ network['ip'] }}
|
||||
NETMASK{{ loop.index }}={{ network['mask'] }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
ONBOOT=yes
|
||||
NAME=loopback
|
Loading…
Reference in New Issue
Block a user