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 %}
|
||||||
[Network]
|
|
||||||
{% if item.1.address is defined %}
|
{%- if item.1.address is not defined %}
|
||||||
{% set addr_cidr = (item.1.address | string + '/' + item.1.netmask | string) | ipaddr('prefix') %}
|
{# Address is not defined #}
|
||||||
Address={{ item.1.address }}/{{ addr_cidr }}
|
{% set _addresses = [] %}
|
||||||
{% elif item.1.address is defined and (item.1.address | lower) == 'dhcp' %}
|
{% elif item.1.address is iterable and not string %}
|
||||||
DHCP=yes
|
{# Address is a list, multiple addresses defined #}
|
||||||
|
{% set _addresses = item.1.address %}
|
||||||
|
{% else %}
|
||||||
|
{# Single address defined #}
|
||||||
|
{% set _addresses = [item.1] %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.1.address is defined and item.1.gateway is defined %}
|
|
||||||
|
[Network]
|
||||||
|
{% for _addr in _addresses %}
|
||||||
|
{% if _addr.address == 'dhcp' %}
|
||||||
|
DHCP=yes
|
||||||
|
{% else %}
|
||||||
|
{% 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