Browse Source

fastd: improvements

- let nem bat_iface depend on node roles
- disable default fastd service
- trigger restart on peer changes
- remove obsolete intergw-peers
- add option no_peer to pillar
- add cron-job to update peers git
Karsten Böddeker 7 years ago
parent
commit
4bdd16b0c3
5 changed files with 38 additions and 28 deletions
  1. 2 2
      fastd/fastd.conf
  2. 0 5
      fastd/ff_update_peers.cron
  3. 19 10
      fastd/init.sls
  4. 8 7
      fastd/inter-gw.peer.tmpl
  5. 9 4
      fastd/peers.sls

+ 2 - 2
fastd/fastd.conf

@@ -45,11 +45,11 @@ on up "
 	ip link set address {{ mac_address }} dev $INTERFACE
 	ifconfig $INTERFACE up
 
-	batctl -m bat-{{ site }}-ext if add $INTERFACE
+	batctl -m {{ bat_iface }} if add $INTERFACE
 ";
 
 on down "
-	batctl -m bat-{{ site }}-ext if del $INTERFACE
+	batctl -m {{ bat_iface }} if del $INTERFACE
 ";
 
 {%- if 'nodes' in network %}

+ 0 - 5
fastd/ff_update_peers.cron

@@ -1,5 +0,0 @@
-# Update /etc/freifunk/peers repository
-
-MAILTO="{{ salt['pillar.get']('ffho:tech_c_mail') }}"
-
-*/5 * * * *     root    /usr/local/sbin/ff_update_peers 2>&1 | /usr/local/bin/ff_log_to_bot

+ 19 - 10
fastd/init.sls

@@ -30,6 +30,8 @@ fastd:
     - require:
       - pkgrepo: fastd-repo
       - sls: network.interfaces
+  service.dead:
+    - enable: False
 
 /etc/systemd/system/fastd@.service:
   file.managed:
@@ -76,6 +78,11 @@ fastd:
       site: {{ site }}
       site_no: {{ site_no }}
       mac_address: {{ mac_address }}
+    {% if 'batman_ext' in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
+      bat_iface: bat-{{ site }}-ext
+    {% else %}
+      bat_iface: bat-{{ site }}
+    {% endif %}
       peer_limit: {{ salt['pillar.get']('nodes:' ~ grains['id'] ~ ':fastd:peer_limit', False) }}
     - require:
       - file: /etc/fastd/{{ instance_name }}
@@ -102,9 +109,15 @@ fastd@{{ instance_name }}:
       - file: /etc/systemd/system/fastd@.service
       - file: /etc/fastd/{{ instance_name }}/fastd.conf
       - file: /etc/fastd/{{ instance_name }}/secret.conf
+      - service: fastd
     - watch:
       - file: /etc/fastd/{{ instance_name }}/fastd.conf
       - file: /etc/fastd/{{ instance_name }}/secret.conf
+    {% if network in ['nodes4', 'nodes6'] %}
+      - git: peers-git
+    {% else %}
+      - file: /etc/fastd/{{ instance_name }}/gateways/*
+    {% endif %}
   {% endfor %} # // foreach network in $site
 
 
@@ -118,17 +131,10 @@ fastd@{{ instance_name }}:
       - file: /etc/fastd/{{ site }}_intergw
 
 #
-# Gather all nodes configured for this site
-  {% set nodes = [] %}
-  {% for node, node_config in salt['pillar.get']('nodes').items () %}
-    {% if site in node_config.get ('sites', {}) and 'fastd' in node_config %}
-      {% do nodes.append (node) %}
-    {% endif %}
-  {% endfor %} # // foreach node
-
 # Set up Inter-Gw-VPN link to all nodes of this site
-  {% for node in nodes|sort %}
+  {% for node, node_config in salt['pillar.get']('nodes').items ()|sort  %}
 /etc/fastd/{{ site }}_intergw/gateways/{{ node }}:
+    {% if site in node_config.get ('sites', {}) and 'fastd' in node_config %}
   file.managed:
     - source: salt://fastd/inter-gw.peer.tmpl
     - template: jinja
@@ -138,7 +144,10 @@ fastd@{{ instance_name }}:
       pubkey: {{ salt['pillar.get']('nodes:' ~ node ~ ':fastd:intergw_pubkey') }}
     - require:
       - file: /etc/fastd/{{ site }}_intergw/gateways
-  {% endfor %} # // foreach site peer
+    {% else %}
+  file.absent
+    {% endif %}
+  {% endfor %} # // foreach node
 {% endfor %} # // foreach site
 
 

+ 8 - 7
fastd/inter-gw.peer.tmpl

@@ -1,15 +1,16 @@
 # Peer config for {{ node }} in site {{ site }} (Salt managed)
 {%- set node_config = salt['pillar.get']('nodes:' ~ node) %}
+{%- set no_peer = salt['pillar.get']('nodes:' ~ node ~ ':fastd:no_peer', False) %}
 {%- set ips = salt['ffho_net.get_node_iface_ips'](node_config, 'vrf_external') %}
 
-{# {%- if not no_peer %} #}
-{%- set port = 11000 + site_no|int %}
-{%- for ipv4 in ips['v4'] %}
+{%- if not no_peer %}
+  {%- set port = 11000 + site_no|int %}
+  {%- for ipv4 in ips['v4'] %}
 remote ipv4 "{{ ipv4 }}" port {{ port }};
-{%- endfor %}
-{%- for ipv6 in ips['v6'] %}
+  {%- endfor %}
+  {%- for ipv6 in ips['v6'] %}
 remote ipv6 "{{ ipv6 }}" port {{ port }};
-{%- endfor %}
-{# {%- endif %} #}
+  {%- endfor %}
+{%- endif %}
 
 key "{{ pubkey }}";

+ 9 - 4
fastd/peers.sls

@@ -28,7 +28,12 @@ peers-git:
     - mode: 744
 
 ## update cronjob
-#/etc/cron.d/ff_update_peers:
-#  file.managed:
-#    - source: salt://fastd/ff_update_peers.cron
-#
+fastd-update-peers:
+  cron.present:
+    - name: /usr/local/sbin/ff_update_peers 2>&1 | /usr/local/bin/ff_log_to_bot
+    - identifier: fastd-update-peers
+    - user: root
+    - minute: '*/5'
+    - require:
+      - file: /usr/local/sbin/ff_update_peers
+      - git: peers-git