Skip to content

Commit

Permalink
add mmfd + respondd
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Feb 3, 2019
1 parent ea4c407 commit 1805800
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def host(self, id, hostname, **host_vars):
vars.update(host_vars)
vars.update({
"vpn_id": id,
"babel": self.babel,
"batman_ipv4": self.calculate_address("ipv4_network", id),
"batman_ipv6_global": self.calculate_address("ipv6_global_network", id),
"batman_ipv6_local": self.calculate_address("ipv6_local_network", id),
Expand Down
9 changes: 7 additions & 2 deletions playbooks/babelserver.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
---
- hosts: babelservers
vars:
mesh_announce_git_root: https://github.com/FreifunkBremen/mesh-announce
mesh_announce_git_commit: babel
roles:
- apt
- openssh
- { role: babeld, tags: [ babeld, babel ] }
- { role: l3roamd, tags: [ l3roamd, babel ] }
- { role: wireguard, tags: [ wireguard, babel ] }
# - { role: l3roamd, tags: [ l3roamd, babel ] }
- { role: mmfd, tags: [ mmfd, babel ] }
- { role: wireguard, tags: [ wireguard, vpn ] }
- { role: mesh-announce, tags: respondd }
- system
- tmpfs
- tools
Expand Down
4 changes: 3 additions & 1 deletion roles/babeld/templates/firewall.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# babeld
# babeld control
ipt -A INPUT -i lo -p tcp --dport 33123 -j ACCEPT

# babeld routing
{% for ifname in babel_interfaces %}
ipt6 -A INPUT -i {{ifname}} -p udp --dport 6696 -j ACCEPT
{% endfor %}
6 changes: 6 additions & 0 deletions roles/mesh-announce/templates/firewall.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# batman
ipt6 -A INPUT -i {{ main_bridge }} -p udp --dport 1001 -j ACCEPT
ipt6 -A INPUT -i vpn-{{ site_code }}-legacy -p udp --dport 1001 -j ACCEPT
ipt6 -A INPUT -i vpn-{{ site_code }} -p udp --dport 1001 -j ACCEPT

# babel
ipt6 -A INPUT -i lo -p udp --dport 1001 -j ACCEPT
ipt6 -A INPUT -i babel-ffhb -p udp --dport 1001 -j ACCEPT
ipt6 -A INPUT -i mmfd0 -p udp --dport 1001 -j ACCEPT
4 changes: 4 additions & 0 deletions roles/mesh-announce/templates/service
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ Description=Respondd
After=network.target

[Service]
{% if babel %}
ExecStart=/opt/{{ site_code }}/mesh-announce/respondd.py -d /opt/{{ site_code }}/mesh-announce/providers -g ff05::2:1001 -i {{ babel_bridge }} -ba [::]:33123
{% else %}
{% if respondd_vpn %}
ExecStart=/opt/{{ site_code }}/mesh-announce/respondd.py -d /opt/{{ site_code }}/mesh-announce/providers -b {{ batman_interface }} -i {{ main_bridge }} -i vpn-{{ site_code }}-legacy -i vpn-{{ site_code }}
{% else %}
ExecStart=/opt/{{ site_code }}/mesh-announce/respondd.py -d /opt/{{ site_code }}/mesh-announce/providers -b {{ ansible_default_ipv4.interface }} -i {{ ansible_default_ipv4.interface }}
{% endif %}
{% endif %}

[Install]
WantedBy=multi-user.target
5 changes: 5 additions & 0 deletions roles/mmfd/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
mmfd_repository: "https://dl.ffm.freifunk.net/debian-packages/ sid main"
mmfd_repository_key: 390BF305

babel_bridge: babel-{{ site_code }}
6 changes: 6 additions & 0 deletions roles/mmfd/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: restart mmfd
service: name=mmfd state=restarted

- name: reload systemd
command: systemctl daemon-reload
31 changes: 31 additions & 0 deletions roles/mmfd/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- name: Add repository key for babeld and utils
apt_key: keyserver="{{ pgp_keyserver }}" id="{{mmfd_repository_key}}"

- name: Add repository for babeld and utils
apt_repository: repo="deb {{mmfd_repository}}"

- name: Install mmfd (babel utils)
apt: name="mmfd"

- name: Install interfaces file
template: >
src=interfaces
dest=/etc/network/interfaces.d/babel-{{site_code}}-mmfd
- name: Configure firewall
template: src=firewall.sh dest={{ firewall_path }}/35-babel-{{site_code}}-mmfd
when: firewall_enabled
notify: reload firewall

- name: Install mmfd service
template: src=mmfd.service dest=/etc/systemd/system/mmfd.service
notify:
- reload systemd
- restart mmfd

- name: Enable mmfd
service:
name: mmfd
enabled: yes
state: started

2 changes: 2 additions & 0 deletions roles/mmfd/templates/firewall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# mmfd
ipt -A INPUT -i {{babel_bridge}} -p udp --dport 27275 -j ACCEPT
8 changes: 8 additions & 0 deletions roles/mmfd/templates/interfaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# {{ ansible_managed }}

allow-hotplug mmfd0
auto mmfd0
iface mmfd0 inet6 static
address fe80::1
netmask 64
post-up ip r add ff05::2:1001/128 dev mmfd0 table local
14 changes: 14 additions & 0 deletions roles/mmfd/templates/mmfd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=mmfd
Wants=basic.target
After=basic.target network.target babeld.service

[Service]
Type=simple
ExecStart=/usr/local/bin/mmfd
KillMode=process
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

0 comments on commit 1805800

Please sign in to comment.