ibgp.conf 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #
  2. # FFHO iBGP configuration (Salt managed)
  3. #
  4. template bgp ibgp {
  5. import filter ibgp_in;
  6. export filter ibgp_out;
  7. local as AS_OWN;
  8. source address LO_IP;
  9. enable route refresh yes;
  10. graceful restart yes;
  11. }
  12. {#- Gather information for iBGP sessions #}
  13. {%- set roles = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  14. {%- set peers = [] %}
  15. {%- for node in salt['pillar.get']('nodes', [])|sort if node != grains['id'] %}
  16. {%- set peer_node_config = salt['pillar.get']('nodes:' ~ node) %}
  17. {%- set peer_roles = peer_node_config.get ('roles', []) %}
  18. {#- save peers node name, mangle . and - to _ to make bird happy #}
  19. {%- set peer_config = { 'node' : salt['ffho.re_replace']('[.-]', '_', node) } %}
  20. {%- if 'router' in peer_roles %}
  21. {#- Skip peer if neither we nor him are a RR #}
  22. {%- if 'routereflector' not in roles and 'routereflector' not in peer_roles %}
  23. {%- continue %}
  24. {%- endif %}
  25. {#- Don't try to set up sessions to VMs/devices which are "planned", "failed", "decomissioning" and "inventory" #}
  26. {%- if peer_node_config.get ('status', '') not in [ '', 'active', 'staged', 'offline' ] %}
  27. {%- continue %}
  28. {%- endif %}
  29. {#- Is our peer a route reflector? #}
  30. {%- if 'routereflector' in peer_roles %}
  31. {%- do peer_config.update ({'rr' : True }) %}
  32. {%- endif %}
  33. {#- get peers Lo IP #}
  34. {%- do peer_config.update ({ 'ip' : salt['ffho_net.get_primary_ip'] (peer_node_config, proto).ip }) %}
  35. {%- do peers.append (peer_config) %}
  36. {%- endif %}
  37. {%- endfor %}
  38. {#- configure iBGP sessions #}
  39. {% for peer_config in peers %}
  40. protocol bgp {{ peer_config.get ('node') }} from ibgp {
  41. neighbor {{ peer_config.get ('ip') }} as AS_OWN;
  42. {%- if 'routereflector' in roles and not 'rr' in peer_config %}
  43. rr client;
  44. {%- endif %}
  45. }
  46. {% endfor %}