Files
Ansible-Bootstrap/roles/virtualization/templates/cloud-network-config.yml.j2

43 lines
1.1 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_list = system_cfg.dns.servers | default([]) %}
{% set search_list = system_cfg.dns.search | default([]) %}
{% 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 dns_list | length or search_list | length %}
dhcp4-overrides:
{% if dns_list | length %}
use-dns: false
{% endif %}
{% if search_list | 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 %}