openstack-ansible-lxc_conta.../templates/container_network.network.j2

38 lines
954 B
Django/Jinja

[Match]
Name={{ item.value.interface }}
{% if item.value.address is defined %}
[Address]
{% set addr_cidr = (item.value.address | string + '/' + item.value.netmask | string) | ipaddr('prefix') %}
Address={{ item.value.address }}/{{ addr_cidr }}
{% else %}
[DHCP]
UseDNS={{ (lxc_container_enable_resolved | bool) | ternary('yes', 'no') }}
UseNTP=yes
RouteMetric=20
{% endif %}
{% for route in item.value.static_routes | default([]) %}
[Route]
Source={{ route['cidr'] }}
Gateway={{ route['gateway'] }}
Metric={{ 20 + loop.index }}
{% endfor %}
[Network]
{% if item.value.address is defined %}
{% set addr_cidr = (item.value.address | string + '/' + item.value.netmask | string) | ipaddr('prefix') %}
Address={{ item.value.address }}/{{ addr_cidr }}
{% else %}
DHCP=yes
{% endif %}
{% if item.value.gateway is defined %}
Gateway={{ item.value.gateway }}
{% endif %}
[Link]
{% if item.value.mtu is defined %}
MTUBytes={{ item.value.mtu }}
{% endif %}