This commit is contained in:
2021-10-30 02:35:49 +02:00
parent ab2a578955
commit f662fe0f30
17 changed files with 807 additions and 81 deletions

View File

@ -8,80 +8,119 @@
# {{ config.headline }}
#-----------------------------
{% endif %}
{% endif %}
{# {% if config.auto is defined and config.auto is sameas true %} #}
{% if config.auto | default(loop.first) %}
auto {{ config.device }}
{% endif %}
{% endif %}
{% for stanza in config.allow | default([]) %}
allow-{{ stanza }}
{% endfor -%}
iface {{ config.device }} {{ config.family | default('inet', true) }} {{ config.method | default('static', true) }}
{% set iface_keys = ['hwaddress ether', 'description', 'address', 'netmask', 'network', 'broadcast', 'gateway'] %}
{% for key in iface_keys %}
{% if key in config %}
{{ key }} {{ config[key] }}
{% if config.method == "static" %}
{% if config.description is defined %}
description {{ config.description }}
{% endif %}
{% endfor -%}
{% if config.hwaddress is defined %}
hwaddress {{ config.hwaddress }}
{% endif %}
{% if (config.address is defined) and (0 < config.address | length) %}
{% if config.netmask is defined %}
address {{ config.address }}/{{ config.netmask }}
{% else %}
address {{ config.address }}
{% endif -%}
{% endif -%}
{% set iface_keys = ['gateway', 'metric', 'pointopoint', 'mtu', 'scope'] %}
{% for key in iface_keys %}
{% if key in config %}
{{ key }} {{ config[key] }}
{% endif %}
{% endfor -%}
{% elif config.method == "manual" %}
{% set iface_keys = ['hwaddress', 'mtu'] %}
{% for key in iface_keys %}
{% if key in config %}
{{ key }} {{ config[key] }}
{% endif %}
{% endfor -%}
{% elif config.method == "dhcp" %}
{% set iface_keys = ['hwaddress', 'hostname', 'metric', 'leasehours', 'vendor', 'client' ] %}
{% for key in iface_keys %}
{% if key in config %}
{{ key }} {{ config[key] }}
{% endif %}
{% endfor -%}
{% elif config.method == "bootp" %}
{% set iface_keys = ['hwaddr', 'bootfile', 'server'] %}
{% for key in iface_keys %}
{% if key in config %}
{{ key }} {{ config[key] }}
{% endif %}
{% endfor -%}
{% endif %}
{# #}
{# nameservers #}
{%- if (config.nameservers is defined) and (0 < config.nameservers | length) %}
# nameserver settings
# dns-* options are implemented by the resolvconf package, if installed
# sets entries in /etc/resolv.conf
#
dns-nameservers {{ config.nameservers | join(' ') }}
{% endif %}
{% if config.dns_search is defined %}
dns-search {{ config.dns_search }}
{% endif -%}
{% endif -%}
{# #}
{# subnets #}
{%- if (config.subnets is defined) and (0 < config.subnets | length) %}
# additional subnets
{% for subnet in config.subnets %}
up /sbin/ip addr add {{ subnet }} dev {{ config.device }}
down /sbin/ip addr del {{ subnet }} dev {{ config.device }}
{% endfor %}
{% endif -%}
{% endif -%}
{# #}
{# bridge settings #}
{%- if config['bridge'] is defined %}
# bridge settings
{% for key in config.bridge %}
bridge_{{ key }} {{ config.bridge[key] }}
{% endfor %}
{% endif -%}
{# #}
{# bond parameters #}
{% set bond_keys = ['mode', 'miimon', 'downdelay', 'updelay', 'master', 'slaves', 'lacp-rate'] %}
{% set bond_keys = ['master', 'primary', 'slaves', 'mode', 'miimon', 'lacp-rate', 'ad-select', 'downdelay', 'updelay'] %}
{%- if (config.bond is defined) and (bond_keys | intersect(config.bond.keys())) -%}
# bond parameters
{% for key in bond_keys %}
{% if key in config.bond -%}
bond-{{ key }} {{ config.bond[key] }}
{% endif %}
{% endfor %}
{% endif -%}
{# #}
{% endif -%}
{# vlan #}
{% set vlan_keys = ['raw-device'] %}
{%- if (config.vlan is defined) and (vlan_keys | intersect(config.vlan.keys())) -%}
# vlan
{% for key in vlan_keys %}
{% if key in config.vlan -%}
vlan-{{ key }} {{ config.vlan[key] }}
{% endif %}
{% endfor %}
{% endif -%}
{% endfor %}
{# #}
{% endif -%}
{# #}
{# hook scripts #}
{% set hook_keys = ['pre-up', 'up', 'post-up', 'pre-down', 'down', 'post-down'] %}
{%- if hook_keys | intersect(config.keys()) %}
# hook scripts
{% for key in hook_keys %}
{% if key in config %}