ansible-edda/playbooks/roles/services/setup/user/templates/veth/interface

20 lines
1.1 KiB
Plaintext

iface {{ services_service_iface_name }} inet manual
pre-up mkdir -p /run/netns
pre-up ln -sfTv /proc/$(cat {{ services_service_user_containers }}/pidfile)/ns/net /run/netns/{{ services_service_user_name }}
pre-up ip link add name $IFACE type veth peer name veth0 netns {{ services_service_user_name }}
pre-up ip link set $IFACE master br0
post-up ip -n {{ services_service_user_name }} link set veth0 up
post-up ip -n {{ services_service_user_name }} address add {{ services_service_iface_address }}/24 dev veth0
post-up ip -n {{ services_service_user_name }} route add default via {{ services_bridge_gateway }} dev veth0
pre-down ip -n {{ services_service_user_name }} route del default via {{ services_bridge_gateway }} dev veth0
pre-down ip -n {{ services_service_user_name }} address del {{ services_service_iface_address }}/24 dev veth0
pre-down ip -n {{ services_service_user_name }} link set veth0 down
post-down ip link set $IFACE nomaster
post-down ip link del dev $IFACE
post-down rm /run/netns/{{ services_service_user_name }}