ansible-ffibk/roles/network-meshbridge/templates/bridge.j2
Tobias Hachmer 94cb21daad Add a bunch of new roles
- Update Readme
- Update ansible.cfg
- Add playbook to set up gateways
- Add group variables
2017-09-11 23:21:44 +02:00

22 lines
1.1 KiB
Django/Jinja

{% set ip4hex = item.value.ipv4_network | ipaddr('net') | ipaddr(magic) | ipaddr('address') | ip4_hex() -%}
{% set mac = '0210' + ip4hex -%}
#
# {{ ansible_managed }}
#
auto {{ item.key }}BR
iface {{ item.key }}BR inet manual
address {{ item.value.ipv4_network | ipaddr('net') | ipaddr(magic) | ipaddr('address') }}
network {{ item.value.ipv4_network | ipaddr('net') | ipaddr(magic) | ipaddr('network') }}
netmask {{ item.value.ipv4_network | ipaddr('net') | ipaddr(magic) | ipaddr('netmask') }}
broadcast {{ item.value.ipv4_network | ipaddr('net') | ipaddr(magic) | ipaddr('broadcast') }}
pre-up /sbin/ip link add name $IFACE type bridge
pre-up /sbin/ip link set address {{ mac | hwaddr('linux') }} dev $IFACE
pre-up /sbin/ip link set dev {{ item.key }}BAT master $IFACE
pre-up /sbin/ip link set up dev $IFACE
{% for ip_type, ip_list in item.value.ipv6.iteritems() %}
{% for ip in ip_list %}
up /sbin/ip address add {{ ip | ipaddr('net') | ipsubnet(64, 0) | ipaddr(magic) }} dev $IFACE
{% endfor %}
{% endfor %}
post-down /sbin/ip link set dev {{ item.key }}BAT nomaster
post-down /sbin/ip link delete $IFACE 2>&1 || true