IGP.conf 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #
  2. # FFHO IGP / OSPF configuration (Salt managed)
  3. #
  4. {%- set node_config = salt['pillar.get']('nodes:' ~ grains['id'], {}) %}
  5. {%- set ospf_node_config = node_config.get('ospf', {}) %}
  6. {%- if 'stub_router' in ospf_node_config and ospf_node_config['stub_router'] in [ True, 'yes'] %}
  7. {%- do ospf_node_config.update ({'stub_router': 'yes'}) %}
  8. {%- endif %}
  9. {%- if proto == 'v6' %}
  10. # Bloody workaround for bird6's unwillingness to read !LL IPv6 addresses from lo
  11. protocol direct lo_v6 {
  12. interface "lo";
  13. }
  14. {%- endif %}
  15. protocol ospf IGP {
  16. import all;
  17. {%- if proto == 'v4' %}
  18. {%- if grains['id'].startswith ('cr') %}
  19. export filter {
  20. if net = 0.0.0.0/0 then {
  21. ospf_metric1 = 100;
  22. accept;
  23. }
  24. reject;
  25. };
  26. {%- else %}
  27. export none;
  28. {%- endif %}
  29. {%- elif proto == 'v6' %}
  30. export filter {
  31. {%- if grains['id'].startswith ('cr') %}
  32. if net = ::/0 then {
  33. ospf_metric1 = 100;
  34. accept;
  35. }
  36. {%- endif %}
  37. if proto = "lo_v6" then {
  38. ospf_metric1 = 100;
  39. accept;
  40. }
  41. reject;
  42. };
  43. {%- endif %}
  44. area 0.0.0.0 {
  45. stub {{ ospf_node_config.get ('stub_router', 'no') }} ;
  46. interface "lo" {
  47. stub yes;
  48. };
  49. {#-
  50. # Wired / Wireless IP-Backbone links
  51. #
  52. # Prefer direct Layer2 connections (via Ethernet cable or WBBL) between nodes
  53. # Vlan 10xy are direct wired Ethernet connection
  54. # Vlan 20xy are AF-X based WBBL
  55. # Vlan 22xy are non-AF-X based WBBL
  56. #
  57. # Watch management interfaces as stub interfaces.
  58. #}
  59. {%- set ospf_interface_config = salt['ffho_net.get_ospf_interface_config'](node_config, grains['id']) %}
  60. {%- for iface in ospf_interface_config|sort %}
  61. {%- set config = ospf_interface_config.get (iface) %}
  62. {#- Interface description? #}
  63. {%- set desc = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':ifaces:' ~ iface ~ ':desc', "") %}
  64. # {{ desc }}
  65. interface "{{ iface }}" {
  66. {%- if 'desc' in config %}
  67. # {{ config.get ('desc') }}
  68. {%- endif %}
  69. {%- for attr in config|sort if attr not in ['desc'] %}
  70. {{ attr }} {{ config.get (attr) }};
  71. {%- endfor %}
  72. };
  73. {%- endfor %}
  74. {#-
  75. # Backbone OpenVPNs
  76. #}
  77. {%- set interfaces = {} %}
  78. {%- for vpn, vpn_config in salt['pillar.get']('ovpn', {}).items () %}
  79. {%- if grains['id'] in vpn_config %}
  80. {%- set host_config = vpn_config.get (grains['id'], {}).get ('config', {}) %}
  81. {%- set interface = host_config.get ('interface', vpn_config.get ('interface', '')) %}
  82. {%- if interface.startswith ('ovpn-') %}
  83. {%- do interfaces.update({interface: { 'cost': vpn_config.get (grains['id'], {}).get ('config', {}).get ('cost', False) }}) %}
  84. {%- endif %}
  85. {%- endif %}
  86. {%- endfor %}
  87. {%- for interface, iface_config in interfaces.items()|sort %}
  88. interface "{{ interface }}" {
  89. {%- if interface.startswith ('ovpn-er-') and proto == 'v6' %}
  90. type broadcast;
  91. {%- else %}
  92. type pointopoint;
  93. {%- endif %}
  94. {%- if iface_config.cost %}
  95. cost {{ iface_config.cost }};
  96. {%- elif interface.startswith ('ovpn-cr') %}
  97. cost 5000;
  98. {%- else %}
  99. cost 10000;
  100. {%- endif %}
  101. };
  102. {% endfor %}
  103. {%- if 'veth_int2ext' in node_config.get ('ifaces', {}) %}
  104. # Learn transfer prefix to external VRF for BGP recursive lookup.
  105. interface "veth_int2ext" {
  106. stub yes;
  107. };
  108. {%- endif %}
  109. {%- if grains['id'].startswith ('cr01') %}
  110. interface "tun-ops" {
  111. stub yes;
  112. };
  113. {%- endif %}
  114. };
  115. }