1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #
- # FFHO iBGP configuration (Salt managed)
- #
- template bgp ibgp {
- import filter ibgp_in;
- export filter ibgp_out;
- local as AS_OWN;
- source address LO_IP;
- enable route refresh yes;
- graceful restart yes;
- }
- {#- Gather information for iBGP sessions #}
- {%- set roles = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
- {%- set peers = [] %}
- {%- for node in salt['pillar.get']('nodes', [])|sort if node != grains['id'] %}
- {%- set peer_node_config = salt['pillar.get']('nodes:' ~ node) %}
- {%- set peer_roles = peer_node_config.get ('roles', []) %}
- {#- save peers node name, mangle . and - to _ to make bird happy #}
- {%- set peer_config = { 'node' : salt['ffho.re_replace']('[.-]', '_', node) } %}
- {%- if 'router' in peer_roles %}
- {#- Skip peer if neither we nor him are a RR #}
- {%- if 'routereflector' not in roles and 'routereflector' not in peer_roles %}
- {%- continue %}
- {%- endif %}
- {#- Is our peer a route reflector? #}
- {%- if 'routereflector' in peer_roles %}
- {%- do peer_config.update ({'rr' : True }) %}
- {%- endif %}
- {#- get peers Lo IP #}
- {%- do peer_config.update ({ 'ip' : salt['ffho_net.get_loopback_ip'] (peer_node_config, node, proto)}) %}
- {%- do peers.append (peer_config) %}
- {%- endif %}
- {%- endfor %}
- {#- configure iBGP sessions #}
- {% for peer_config in peers %}
- protocol bgp {{ peer_config.get ('node') }} from ibgp {
- neighbor {{ peer_config.get ('ip') }} as AS_OWN;
- {%- if 'routereflector' in roles and not 'rr' in peer_config %}
- rr client;
- {%- endif %}
- }
- {% endfor %}
|