openstack-ansible-lxc_conta.../templates/veth-cleanup.sh.j2
Logan V d8294284d9 Don't fail veth-cleanup template when no container_networks
veth-cleanup template is broken if container_networks is not defined,
ie. if I have a container with eth0/LXC base nat network only.

Change-Id: I19663e0a32466c54b1b6ba9fadf243aed8055b7e
2016-10-14 12:09:22 -05:00

16 lines
700 B
Django/Jinja

#!/usr/bin/env bash
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# LXC eth0 is considered special and not managed by the base container_networks
# data structure. This is being added outside of the loop for this reason.
ip link del {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_eth0 || true
# Veth cleanup for items in the container_networks data structure
{% if container_networks is defined %}
{% for key, value in container_networks.items() %}
{% if value.type is not defined or value.type == 'veth' %}
ip link del {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_{{ value.interface }} || true
{% endif %}
{% endfor %}
{% endif %}