test: add network template tests

This commit is contained in:
ajschroeder
2024-12-09 22:39:52 +00:00
parent 6c313c97d9
commit dbc24c6688
15 changed files with 227 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
network:
network:
version: 2
ethernets:
%{ if ip != null ~}
${device}:
dhcp4: false
addresses:
- ${ip}/${netmask}
gateway4: ${gateway}
nameservers:
addresses:
%{ for item in dns ~}
- ${item}
%{ endfor ~}
%{ else ~}
${device}:
dhcp4: true
%{ endif ~}

View File

@@ -0,0 +1,5 @@
%{~ if ip != null ~}
network --device=${device} --bootproto=static --ip=${ip} --netmask=${cidrnetmask("${ip}/${netmask}")} --gateway=${gateway} --nameserver=${join(",", dns)}
%{~ else ~}
network --device=${device} --bootproto=dhcp
%{~ endif ~}

View File

@@ -0,0 +1,9 @@
d-i netcfg/choose_interface select ${device}
%{ if ip != null ~}
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/get_ipaddress string ${ip}
d-i netcfg/get_netmask string ${cidrnetmask("${ip}/${netmask}")}
d-i netcfg/get_gateway string ${gateway}
d-i netcfg/get_nameservers string ${join(" ", dns)}
d-i netcfg/confirm_static boolean true
%{ endif ~}