Skip to content
Snippets Groups Projects
Commit 7f83b211 authored by skorpy's avatar skorpy :construction_worker:
Browse files

rr: try to use netbox pillar for rr

parent 5be27b6d
Branches
No related tags found
1 merge request!582rr: try to use netbox pillar for rr
Pipeline #32764 passed
......@@ -52,3 +52,31 @@ def all_peerings(proto):
rule.append('}')
tmp.extend(rule)
return tmp
def internal_peerings(proto):
tmp = []
if 'bgp6' == proto:
source_address = __salt__['pillar.get']('canonical_ip_6',"")
if 'bgp4' == proto:
source_address = __salt__['pillar.get']('canonical_ip_4',"")
for name, peer in sorted(__salt__['pillar.get']('bgp').items()):
peerproto = __salt__['pillar.get'](
'bgp:{0}:{1}'.format(name, proto), [])
if not peerproto:
continue
rule = []
if 'template' in peer:
template = 'from {} '.format(peer['template'])
rule.append('protocol bgp {0} {1}'.format(
name.replace('-', '_').lower(), template) + '{')
rule.append('\tsource address {};'.format(source_address))
rule.append('\tneighbor {0} as {1};'.format(
peerproto['remote'], peer['asn']))
rule.append('}')
tmp.extend(rule)
return tmp
......@@ -3,6 +3,9 @@ template bgp rr_internal from general_ibgp {
export filter internal_out;
rr client;
add paths tx;
gateway recursive;
next hop keep;
igp table dummytab;
}
template bgp rr_ibgp from general_ibgp {
......@@ -10,6 +13,9 @@ template bgp rr_ibgp from general_ibgp {
export filter ibgp_out;
rr client;
add paths tx;
gateway recursive;
next hop keep;
igp table dummytab;
}
#Do not break the legacy!
......@@ -20,4 +26,7 @@ template bgp rr_client from general_bgp {
export filter internal_out;
multihop;
rr client;
gateway recursive;
next hop keep;
igp table dummytab;
}
......@@ -88,3 +88,14 @@ function originate_metro_route()
return 0;
}
{%- endif %}
table dummytable;
protocol static dummystatic {
table dummytable;
{%- if version == "v6" %}
route ::/0 via "lo";
{%- elif version == "v4" %}
route ::/0 via "lo";
{%- endif %}
}
......@@ -4,3 +4,7 @@
{% for peer in salt['peering.all_peerings'](type) %}
{{ peer }}
{%- endfor %}
{% for peer in salt['peering.internal_peerings'](type) %}
{{ peer }}
{%- endfor %}
......@@ -111,7 +111,6 @@
'rr*.as64475.net':
- bird
- bird.bgp
- bird.ospf
- kernel.sysctl
'www2.aixit.off.de.ffffm.net':
- nginx
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment