IGP.conf 3.3 KB

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