瀏覽代碼

We now use ipaddr filter in the templates instead of defining endless variables, which can all be calculated

Till Klocke 9 年之前
父節點
當前提交
15fdf8ed80

+ 8 - 6
roles/ff-supernode/vars/main.yml

@@ -12,11 +12,13 @@ dhcp_common_options:
   - 'wpad "\n\000"'
   - interface-mtu 1280
 dhcp_subnets:
-  - base: "{{supernode_mesh_net_base_ip}}"
-    netmask: "{{supernode_mesh_netmask_ipv4}}"
-    routers: "{{supernode_mesh_ipv4}}"
-    domain_nameservers: "{{supernode_mesh_ipv4}}, {{supernode_other_nameserver}}"
-    ntp_servers: "{{supernode_mesh_ipv4}}, {{supernode_other_ntp_server}}"
+  - base: "{{supernode_mesh_ipv4|ipaddr('network')}}"
+    netmask: "{{supernode_mesh_ipv4|ipaddr('netmask')}}"
+    routers: "{{supernode_mesh_ipv4|ipaddr('address')}}"
+    range_start: "{{supernode_dhcp_range_start}}"
+    range_end: "{{supernode_dhcp_range_end}}"
+    domain_nameservers: "{{supernode_mesh_ipv4|ipaddr('address')}}, {{supernode_other_nameserver}}"
+    ntp_servers: "{{supernode_mesh_ipv4|ipaddr('address')}}, {{supernode_other_ntp_server}}"
 dhcp_classes:
   - name: MSFT
     rule: 'match if substring(option vendor-class-identifier, 0, 4) = "MSFT"'
@@ -30,7 +32,7 @@ radvd_default_interface_options: |
   MaxRtrAdvInterval 600;
   MinDelayBetweenRAs 10;
   AdvLinkMTU 1280;
-  prefix {{supernode_mesh_net_ipv6}}
+  prefix {{supernode_mesh_ipv6|ipaddr('subnet')}}
   {
   };
 

+ 2 - 2
roles/supernode-interfaces/templates/bird.conf.j2

@@ -1,5 +1,5 @@
 log syslog all;
-router id {{supernode_mesh_ipv4}};
+router id {{supernode_mesh_ipv4|ipaddr('address')}};
 
 protocol direct {
         interface "*";
@@ -35,7 +35,7 @@ protocol bgp {{uplink.name}} from ibgp {
 
 {% for meshlink in supernode_mesh_backbones%}
 protocol bgp {{meshlink.name}} from ibgp {
-        source address {{supernode_mesh_ipv4}};
+        source address {{supernode_mesh_ipv4|ipaddr('address')}};
         neighbor {{meshlink.mesh_ip}} as {{supernode_as}};
         default bgp_med 4;
 };

+ 5 - 5
roles/supernode-interfaces/templates/bird6.conf.j2

@@ -1,5 +1,5 @@
 log syslog all;
-router id {{supernode_mesh_ipv4}};
+router id {{supernode_mesh_ipv4|ipaddr('address')}};
 
 protocol static uplink_hostroute {
    import all;
@@ -24,8 +24,8 @@ protocol device {
 }
 
 template bgp ibgp {
-        source address 2a03:2260:50:5::8;
-        local as 65403;
+        source address {{supernode_mesh_ipv6|ipaddr('address')}};
+        local as {{supernode_as}};
         import all;
         export all;
         next hop self;
@@ -34,7 +34,7 @@ template bgp ibgp {
 }
 
 template bgp uplink {
-        local as 65403;
+        local as {{supernode_uplinks[0].as}};
         import all;
         export all;
         next hop self;
@@ -44,7 +44,7 @@ template bgp uplink {
 
 {% for uplink in supernode_uplinks %}
 protocol bgp {{uplink.name}} from uplink {
-        neighbor {{uplink.adress_v6_pure}} as {{uplink.as}};
+        neighbor {{uplink.address_v6|ipaddr('address')}} as {{uplink.as}};
         default bgp_med 2;
 }
 

+ 10 - 10
roles/supernode-interfaces/templates/interfaces.j2

@@ -41,17 +41,17 @@ iface meshdummy0 inet manual
 # batman-adv Mesh Interface, wird von meshdummy0 per Hotplug aktiviert
 allow-hotplug bat0
 iface bat0 inet static
-    address {{supernode_mesh_ipv4}}
-    netmask {{supernode_mesh_netmask_ipv4}}
+    address {{supernode_mesh_ipv4|ipaddr('address')}}
+    netmask {{supernode_mesh_ipv4|ipaddr('netmask')}}
     hwaddress {{supernode_bat_macaddress}}
-    pre-up ip rule add from {{supernode_mesh_net_cidr}} table 42
-    pre-up ip rule add to {{supernode_mesh_net_cidr}} table 42
+    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_net_cidr}} table 42
-    post-down ip rule del to {{supernode_mesh_net_cidr}} table 42
+    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
@@ -61,10 +61,10 @@ iface bat0 inet static
 
 iface bat0 inet6 static
     address {{supernode_mesh_ipv6}}
-    pre-up ip -6 rule add from {{supernode_mesh_net_ipv6}} table 42
-    pre-up ip -6 rule add to {{supernode_mesh_net_ipv6}} table 42
-    post-down ip -6 rule del from {{supernode_mesh_net_ipv6}} table 42
-    post-down ip -6 rule del to {{supernode_mesh_net_ipv6}} table 42
+    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 %}

+ 4 - 6
test/application/supernode_pkg_vars.yml

@@ -1,15 +1,13 @@
 supernode_mesh_mac: 96:48:76:b5:a3:61
-supernode_mesh_ipv4: 10.42.0.1
+supernode_mesh_ipv4: 10.42.0.1/16
 supernode_as: '65403'
-supernode_mesh_net_base_ip: 10.42.0.0
-supernode_mesh_netmask_ipv4: 255.255.0.0
 supernode_bat_macaddress: f2:43:13:c0:d7:06
-supernode_mesh_net_cidr: 10.42.0.0/16
 supernode_mesh_ipv6: 2a03:2260:50:5::8/64
-supernode_mesh_net_ipv6: 2a03:2260:50:5::/64
 supernode_local_ip: "{{ansible_default_ipv4.address}}"
 supernode_other_nameserver: 10.42.0.23
 supernode_other_ntp_server: 10.42.0.23
+supernode_dhcp_range_start: 10.42.9.1
+supernode_dhcp_range_end: 10.42.45.25
 
 supernode_mesh_backbones:
   - name: node02
@@ -26,7 +24,7 @@ supernode_uplinks:
     netmask: 255.255.255.252
     endpoint: 192.168.0.23
     address_v6: fd0a:1c06:d97c:e88d::2/64
-    adress_v6_pure: fd0a:1c06:d97c:e88d::2
+    #adress_v6_pure: fd0a:1c06:d97c:e88d::2
     as: '65079'
 
 fastd_instances: