12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #
- # 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 %}
- {#- Don't try to set up sessions to VMs/devices which are "offline" or "planned" etc. #}
- {%- if peer_node_config.get ('status', '') not in [ '', 'active', 'staged' ] %}
- {%- 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_primary_ip'] (peer_node_config, proto).ip }) %}
- {%- 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 %}
|