Browse Source

bird: Allow OSPF costs to be overwritten for OpenVPN tunnel interfaces.

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
Maximilian Wilhelm 6 years ago
parent
commit
90737f27f0
1 changed files with 6 additions and 4 deletions
  1. 6 4
      bird/IGP.conf

+ 6 - 4
bird/IGP.conf

@@ -87,17 +87,17 @@ protocol ospf IGP {
 {#-
  # Backbone OpenVPNs
  #}
-{%- set interfaces = [] %}
+{%- set interfaces = {} %}
 {%- for vpn, vpn_config in salt['pillar.get']('ovpn', {}).items () %}
   {%- if grains['id'] in vpn_config %}
     {%- set host_config = vpn_config.get (grains['id'], {}).get ('config', {}) %}
     {%- set interface = host_config.get ('interface', vpn_config.get ('interface', '')) %}
     {%- if interface.startswith ('bb-') or interface.startswith ('ovpn-') or interface.startswith ('oob-') %}
-      {%- do interfaces.append (interface) %}
+      {%- do interfaces.update({interface: { 'cost': vpn_config.get (grains['id'], {}).get ('config', {}).get ('cost', False) }}) %}
     {%- endif %}
   {%- endif %}
 {%- endfor %}
-{%- for interface in interfaces|sort %}
+{%- for interface, iface_config in interfaces.items()|sort %}
 		interface "{{ interface }}" {
   {%- if interface.startswith ('ovpn-er-') and proto == 'v6' %}
 			type broadcast;
@@ -105,7 +105,9 @@ protocol ospf IGP {
 			type pointopoint;
   {%- endif %}
 
-  {%- if interface.startswith ('ovpn-cr') %}
+  {%- if iface_config.cost %}
+			cost {{ iface_config.cost }};
+  {%- elif interface.startswith ('ovpn-cr') %}
 			cost 5000;
   {%- else %}
 			cost 10000;