Browse Source

Different interface types are now defined in different files, which should make organization of interface easier

Till Klocke 9 years ago
parent
commit
4e5edd2cc5

+ 0 - 12
roles/internal/supernode-interfaces/tasks/debian.yml

@@ -1,16 +1,4 @@
-- name: Install network config
-  when: supernode_interfaces is defined
-  template: src=interfaces.j2 dest=/etc/network/interfaces
-  register: network_template_installed
-#  notify: Restart network
 
-- name: Install supernode specific sysctl config
-  template: src=supernode.sysctl.j2 dest=/etc/sysctl.d/supernode.conf
-  register: supernode_sysctl_installed
-
-- name: Load sysctl variables
-  when: supernode_sysctl_installed|changed
-  shell: sysctl -p /etc/sysctl.d/supernode.conf || true
 
 - name: Restart network
   when: network_template_installed|changed

+ 23 - 4
roles/internal/supernode-interfaces/tasks/main.yml

@@ -1,11 +1,30 @@
 ---
 # tasks file for supernode-interfaces
 
-- include: debian.yml
-  when: ansible_distribution == 'Debian'
+- name: Install supernode specific sysctl config
+  template: src=supernode.sysctl.j2 dest=/etc/sysctl.d/supernode.conf
+  register: supernode_sysctl_installed
 
-- include: debian.yml
-  when: ansible_distribution == 'Ubuntu'
+- name: Load sysctl variables
+  when: supernode_sysctl_installed|changed
+  shell: sysctl -p /etc/sysctl.d/supernode.conf || true
+
+- name: Ensure interface definitions from other files are included
+  lineinfile:
+    dest: /etc/network/interfaces
+    line: "source /etc/network/interfaces.d/*.cfg"
+
+- name: Install interface definitions
+  template:
+    dest: "/etc/network/interfaces.d/{{item.file}}"
+    src: "{{item.template}}"
+  with_items:
+  - file: mesh.cfg
+    template: mesh_interfaces.j2
+  - file: backbone.cfg
+    template: backbone_interfaces.j2
+  - file: uplink.cfg
+    template: uplink_interfaces.j2
 
 - name: Install bird.conf
   template: src=bird.conf.j2 dest={{bird_config_dir}}/bird.conf

+ 14 - 0
roles/internal/supernode-interfaces/templates/backbone_interfaces.j2

@@ -0,0 +1,14 @@
+{% if supernode_mesh_backbones is defined %}
+{% for backbone in supernode_mesh_backbones %}
+{% if backbone.comment is defined %}
+# {{backbone.comment}}
+{% endif %}
+auto {{backbone.name}}
+iface {{backbone.name}} inet manual
+    pre-up ip link add $IFACE type gretap local {{backbone.local_ip}} remote {{backbone.remote_ip}} dev {{backbone.interface|default(supernode_public_interface)}}
+    pre-up ip link set up dev $IFACE
+    up batctl if add $IFACE
+    post-down ip link set down dev $IFACE
+    post-down ip link del dev $IFACE
+{% endfor %}
+{% endif %}

+ 0 - 107
roles/internal/supernode-interfaces/templates/interfaces.j2

@@ -1,107 +0,0 @@
-# This file describes the network interfaces available on your system
-# and how to activate them. For more information, see interfaces(5).
-
-#
-# This file is generated by ansible
-#
-
-## Host Interfaces
-
-auto lo
-iface lo inet loopback
-
-{%for interface in supernode_interfaces %}
-{% if interface.auto is defined and interface.auto %}
-auto {{interface.name}}
-{% endif %}
-{% if interface.hotplug is defined and interface.hotplug %}
-allow-hotplug {{interface.name}}
-{% endif %}
-iface {{interface.name}} {{interface.proto}} {{interface.type}}
-{% if interface.config is defined %}
-{% for config in interface.config %}
-    {{config.key}} {{config.value}}
-{% endfor %}
-{% endif %}
-
-{% endfor %}
-
-## Supernode / Node Mesh
-
-# Dummy-Interface als MainIF mit manueller MAC fuer batman-adv
-auto meshdummy0
-iface meshdummy0 inet manual
-    pre-up ip link add $IFACE type dummy
-    pre-up ip link set address {{supernode_mesh_mac}} dev $IFACE
-    pre-up ip link set up dev $IFACE
-    post-down ip link set down dev $IFACE
-    post-down ip link del dev $IFACE
-    up batctl if add $IFACE
-
-# batman-adv Mesh Interface, wird von meshdummy0 per Hotplug aktiviert
-allow-hotplug bat0
-iface bat0 inet static
-    address {{supernode_mesh_ipv4|ipaddr('address')}}
-    netmask {{supernode_mesh_ipv4|ipaddr('netmask')}}
-    hwaddress {{supernode_bat_macaddress}}
-    pre-up ip rule add from {{supernode_mesh_ipv4}} table 42
-    pre-up ip rule add to {{supernode_mesh_ipv4}} table 42
-    pre-up batctl it 5000
-    pre-up batctl bl 0
-    pre-up batctl gw server 48mbit/48mbit
-    pre-up echo 120 > /sys/class/net/$IFACE/mesh/hop_penalty
-    post-down ip rule del from {{supernode_mesh_ipv4}} table 42
-    post-down ip rule del to {{supernode_mesh_ipv4}} table 42
-    # Paralleles Macvlan-Interface mit fixer MTU fuer Alfred
-    up ip link add link $IFACE alfred0 type macvlan
-    up ip link set dev alfred0 mtu 1280
-    up ip link set up dev alfred0
-    down ip link set down dev alfred0
-    down ip link del dev alfred0
-
-iface bat0 inet6 static
-    address {{supernode_mesh_ipv6}}
-    pre-up ip -6 rule add from {{supernode_mesh_ipv6|ipaddr('cidr')}} table 42
-    pre-up ip -6 rule add to {{supernode_mesh_ipv6|ipaddr('cidr')}} table 42
-    post-down ip -6 rule del from {{supernode_mesh_ipv6|ipaddr('cidr')}} table 42
-    post-down ip -6 rule del to {{supernode_mesh_ipv6|ipaddr('cidr')}} table 42
-    #pre-up ebtables -A FORWARD -p IPv6 -i $IFACE --ip6-proto ipv6-icmp --ip6-icmp-type router-advertisement -j DROP
-
-{% if supernode_mesh_backbones is defined %}
-{% for backbone in supernode_mesh_backbones %}
-{% if backbone.comment is defined %}
-# {{backbone.comment}}
-{% endif %}
-auto {{backbone.name}}
-iface {{backbone.name}} inet manual
-    pre-up ip link add $IFACE type gretap local {{backbone.local_ip}} remote {{backbone.remote_ip}} dev {{backbone.interface|default(supernode_public_interface)}}
-    pre-up ip link set up dev $IFACE
-    up batctl if add $IFACE
-    post-down ip link set down dev $IFACE
-    post-down ip link del dev $IFACE
-{% endfor %}
-{% endif %}
-
-## Uplink-Tunnel zum FFRG/FFRL-Backbone
-
-{% if supernode_uplinks is defined %}
-{% for uplink in supernode_uplinks %}
-{% if uplink.comment is defined %}
-# {{uplink.comment}}
-{% endif %}
-auto {{uplink.name}}
-iface {{uplink.name}} inet tunnel
-    mode gre
-    address {{uplink.address}}
-    dstaddr {{uplink.dstaddr}}
-    netmask {{uplink.netmask}}
-    local {{supernode_local_ip|ipaddr('address')}}
-    endpoint {{uplink.endpoint}}
-    mtu 1400
-    ttl 64
-
-iface {{uplink.name}} inet6 static
-    address {{uplink.address_v6}}
-
-{% endfor %}
-{% endif %}

+ 40 - 0
roles/internal/supernode-interfaces/templates/mesh_interfaces.j2

@@ -0,0 +1,40 @@
+# Mesh interfaces
+
+# Dummy-Interface als MainIF mit manueller MAC fuer batman-adv
+auto meshdummy0
+iface meshdummy0 inet manual
+    pre-up ip link add $IFACE type dummy
+    pre-up ip link set address {{supernode_mesh_mac}} dev $IFACE
+    pre-up ip link set up dev $IFACE
+    post-down ip link set down dev $IFACE
+    post-down ip link del dev $IFACE
+    up batctl if add $IFACE
+
+# batman-adv Mesh Interface, wird von meshdummy0 per Hotplug aktiviert
+allow-hotplug bat0
+iface bat0 inet static
+    address {{supernode_mesh_ipv4|ipaddr('address')}}
+    netmask {{supernode_mesh_ipv4|ipaddr('netmask')}}
+    hwaddress {{supernode_bat_macaddress}}
+    pre-up ip rule add from {{supernode_mesh_ipv4}} table 42
+    pre-up ip rule add to {{supernode_mesh_ipv4}} table 42
+    pre-up batctl it 5000
+    pre-up batctl bl 0
+    pre-up batctl gw server 48mbit/48mbit
+    pre-up echo 120 > /sys/class/net/$IFACE/mesh/hop_penalty
+    post-down ip rule del from {{supernode_mesh_ipv4}} table 42
+    post-down ip rule del to {{supernode_mesh_ipv4}} table 42
+    # Paralleles Macvlan-Interface mit fixer MTU fuer Alfred
+    up ip link add link $IFACE alfred0 type macvlan
+    up ip link set dev alfred0 mtu 1280
+    up ip link set up dev alfred0
+    down ip link set down dev alfred0
+    down ip link del dev alfred0
+
+iface bat0 inet6 static
+    address {{supernode_mesh_ipv6}}
+    pre-up ip -6 rule add from {{supernode_mesh_ipv6|ipaddr('cidr')}} table 42
+    pre-up ip -6 rule add to {{supernode_mesh_ipv6|ipaddr('cidr')}} table 42
+    post-down ip -6 rule del from {{supernode_mesh_ipv6|ipaddr('cidr')}} table 42
+    post-down ip -6 rule del to {{supernode_mesh_ipv6|ipaddr('cidr')}} table 42
+    #pre-up ebtables -A FORWARD -p IPv6 -i $IFACE --ip6-proto ipv6-icmp --ip6-icmp-type router-advertisement -j DROP

+ 23 - 0
roles/internal/supernode-interfaces/templates/uplink_interfaces.j2

@@ -0,0 +1,23 @@
+## Uplink-Tunnel zum FFRG/FFRL-Backbone
+
+{% if supernode_uplinks is defined %}
+{% for uplink in supernode_uplinks %}
+{% if uplink.comment is defined %}
+# {{uplink.comment}}
+{% endif %}
+auto {{uplink.name}}
+iface {{uplink.name}} inet tunnel
+    mode gre
+    address {{uplink.address}}
+    dstaddr {{uplink.dstaddr}}
+    netmask {{uplink.netmask}}
+    local {{supernode_local_ip|ipaddr('address')}}
+    endpoint {{uplink.endpoint}}
+    mtu 1400
+    ttl 64
+
+iface {{uplink.name}} inet6 static
+    address {{uplink.address_v6}}
+
+{% endfor %}
+{% endif %}