Merge pull request #3 from Logan2211/multiple-addresses
Accept multiple addresses on an interface
This commit is contained in:
commit
48e9cfbcdf
@ -3,11 +3,7 @@
|
|||||||
[Match]
|
[Match]
|
||||||
Name={{ item.1.interface }}
|
Name={{ item.1.interface }}
|
||||||
|
|
||||||
{% if item.1.address is defined %}
|
{% if item.1.address is defined and (item.1.address | lower) == 'dhcp' %}
|
||||||
[Address]
|
|
||||||
{% set addr_cidr = (item.1.address | string + '/' + item.1.netmask | string) | ipaddr('prefix') %}
|
|
||||||
Address={{ item.1.address }}/{{ addr_cidr }}
|
|
||||||
{% elif item.1.address is defined and (item.1.address | lower) == 'dhcp' %}
|
|
||||||
[DHCP]
|
[DHCP]
|
||||||
UseDNS={{ (item.1.usedns | default(false) | bool) | ternary('yes', 'no') }}
|
UseDNS={{ (item.1.usedns | default(false) | bool) | ternary('yes', 'no') }}
|
||||||
UseNTP=yes
|
UseNTP=yes
|
||||||
@ -21,16 +17,30 @@ Gateway={{ route['gateway'] }}
|
|||||||
Metric={{ 20 + loop.index }}
|
Metric={{ 20 + loop.index }}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{%- if item.1.address is not defined %}
|
||||||
|
{# Address is not defined #}
|
||||||
|
{% set _addresses = [] %}
|
||||||
|
{% elif item.1.address is iterable and not string %}
|
||||||
|
{# Address is a list, multiple addresses defined #}
|
||||||
|
{% set _addresses = item.1.address %}
|
||||||
|
{% else %}
|
||||||
|
{# Single address defined #}
|
||||||
|
{% set _addresses = [item.1] %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[Network]
|
[Network]
|
||||||
{% if item.1.address is defined %}
|
{% for _addr in _addresses %}
|
||||||
{% set addr_cidr = (item.1.address | string + '/' + item.1.netmask | string) | ipaddr('prefix') %}
|
{% if _addr.address == 'dhcp' %}
|
||||||
Address={{ item.1.address }}/{{ addr_cidr }}
|
|
||||||
{% elif item.1.address is defined and (item.1.address | lower) == 'dhcp' %}
|
|
||||||
DHCP=yes
|
DHCP=yes
|
||||||
{% endif %}
|
{% else %}
|
||||||
{% if item.1.address is defined and item.1.gateway is defined %}
|
{% set _addr_cidr = (item.1.address | string + '/' + item.1.netmask | default('') | string).rstrip('/') | ipaddr('host/prefix') %}
|
||||||
|
Address={{ _addr_cidr }}
|
||||||
|
{% endif %}
|
||||||
|
{% if _addr.gateway is defined %}
|
||||||
Gateway={{ item.1.gateway }}
|
Gateway={{ item.1.gateway }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
{% if item.1.bridge is defined %}
|
{% if item.1.bridge is defined %}
|
||||||
Bridge={{ item.1.bridge }}
|
Bridge={{ item.1.bridge }}
|
||||||
{% elif item.1.bond is defined %}
|
{% elif item.1.bond is defined %}
|
||||||
|
Loading…
Reference in New Issue
Block a user