47 lines
1.7 KiB
Django/Jinja
47 lines
1.7 KiB
Django/Jinja
network:
|
|
version: 2
|
|
ethernets:
|
|
id0:
|
|
match:
|
|
macaddress: "{{ virtualization_mac_address }}"
|
|
{% set has_static = system_cfg.ip is defined and system_cfg.ip | string | length %}
|
|
{% set dns_value = system_cfg.dns_servers if system_cfg.dns_servers is defined else '' %}
|
|
{% set dns_list_raw = dns_value if dns_value is iterable and dns_value is not string else dns_value.split(',') %}
|
|
{% set dns_list = dns_list_raw | map('trim') | reject('equalto', '') | list %}
|
|
{% set search_value = system_cfg.dns_search if system_cfg.dns_search is defined else '' %}
|
|
{% set search_list_raw = search_value if search_value is iterable and search_value is not string else search_value.split(',') %}
|
|
{% set search_list = search_list_raw | map('trim') | reject('equalto', '') | list %}
|
|
{% if has_static %}
|
|
addresses:
|
|
- "{{ system_cfg.ip }}/{{ system_cfg.prefix }}"
|
|
{% if system_cfg.gateway is defined and system_cfg.gateway | string | length %}
|
|
gateway4: "{{ system_cfg.gateway }}"
|
|
{% endif %}
|
|
{% else %}
|
|
dhcp4: true
|
|
{% if (system_cfg.dns_servers is defined and system_cfg.dns_servers | length) or (system_cfg.dns_search is defined and system_cfg.dns_search | length) %}
|
|
dhcp4-overrides:
|
|
{% if system_cfg.dns_servers is defined and system_cfg.dns_servers | length %}
|
|
use-dns: false
|
|
{% endif %}
|
|
{% if system_cfg.dns_search is defined and system_cfg.dns_search | length %}
|
|
use-domains: false
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if dns_list or search_list %}
|
|
nameservers:
|
|
{% if dns_list %}
|
|
addresses:
|
|
{% for dns in dns_list %}
|
|
- "{{ dns }}"
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if search_list %}
|
|
search:
|
|
{% for search in search_list %}
|
|
- "{{ search }}"
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endif %}
|