Skip to content

Instantly share code, notes, and snippets.

@cloudnull
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudnull/75663cbfab7b126e4db1 to your computer and use it in GitHub Desktop.
Save cloudnull/75663cbfab7b126e4db1 to your computer and use it in GitHub Desktop.
add mtu to container
# Modified from file os-ansible-deployment/blob/juno/rpc_deployment/roles/container_common/templates/container_interface_file.j2
{%- set used_interfaces = [] %}
{%- for net in provider_networks %}
{%- if net.network.container_interface not in used_interfaces %}
{%- for group in net.network.group_binds if group in hostvars[inventory_hostname]['group_names'] %}
{%- if net.network.container_interface not in used_interfaces %}
{%- if used_interfaces.append(net.network.container_interface) %}{%- endif %}
{%- endif %}
{%- endfor %}
{% if net.network.container_interface in used_interfaces %}
{% if net.network.container_bridge != management_bridge %}
auto {{ net.network.container_interface }}
{% if 'ip_from_q' in net.network and hostvars[inventory_hostname][net.network.ip_from_q + '_address'] is defined %}
iface {{ net.network.container_interface }} inet static
address {{ hostvars[inventory_hostname][net.network.ip_from_q + '_address'] }}
netmask {{ net.network.subnetmask|default(hostvars[inventory_hostname][net.network.ip_from_q + '_netmask']) }}
mtu {{ net.network.mtu | default(1500) }}
{% else %}
iface {{ net.network.container_interface }} inet manual
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
# Used Devices: {{ used_interfaces }}
# The container interface variable is a a default object that assume the
# Ansible iterator type is `with_dict`.
lxc_container_interface: |
### start generated network for [ {{ item.value.interface }} ] ###
auto {{ item.value.interface }}
{% if item.value.address is defined %}
iface {{ item.value.interface }} inet static
address {{ item.value.address }}
netmask {{ item.value.netmask }}
{% if item.value.gateway is defined %}
gateway {{ item.value.gateway }}
{% endif %}
mtu {{ item.value.mtu | default(1500) }}
{% else %}
iface {{ item.value.interface }} inet manual
{% endif %}
### end generated network for [ {{ item.value.interface }} ] ###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment