fix: configurable OVMF/machine type, routes syntax, package lists, interface names

This commit is contained in:
2026-02-20 18:47:12 +01:00
parent d0ae20911b
commit 5dd84c6b39
6 changed files with 32 additions and 11 deletions

View File

@@ -147,21 +147,27 @@ bootstrap_archlinux: >-
bootstrap_alpine: >-
{{
['alpine-base', 'vim']
['alpine-base', 'btrfs-progs', 'chrony', 'curl', 'e2fsprogs',
'logrotate', 'lvm2', 'python3', 'rsync', 'sudo',
'util-linux', 'vim', 'xfsprogs']
+ [('openssh' if system_cfg.features.ssh.enabled | bool else '')]
+ bootstrap_common_conditional
}}
bootstrap_opensuse: >-
{{
['vim']
['btrfs-progs', 'chrony', 'curl', 'e2fsprogs',
'glibc-locale', 'logrotate', 'lvm2', 'NetworkManager',
'python3', 'rsync', 'sudo', 'vim', 'xfsprogs']
+ [('openssh' if system_cfg.features.ssh.enabled | bool else '')]
+ bootstrap_common_conditional
}}
bootstrap_void: >-
{{
['vim']
['btrfs-progs', 'chrony', 'curl', 'dhcpcd', 'e2fsprogs',
'logrotate', 'lvm2', 'python3', 'rsync', 'sudo',
'vim', 'xfsprogs']
+ [('openssh' if system_cfg.features.ssh.enabled | bool else '')]
+ bootstrap_common_conditional
}}

View File

@@ -35,7 +35,12 @@
- name: Copy NetworkManager keyfile per interface
vars:
configuration_iface: "{{ item }}"
configuration_iface_name: "{{ configuration_detected_interfaces[idx] | default('eth' ~ idx) }}"
configuration_iface_name: >-
{{
item.name
if (item.name | default('') | string | length) > 0
else (configuration_detected_interfaces[idx] | default('eth' ~ idx))
}}
configuration_net_uuid: "{{ ('LAN-' ~ idx ~ '-' ~ hostname) | ansible.builtin.to_uuid }}"
ansible.builtin.template:
src: network.j2
@@ -66,7 +71,9 @@
auto lo
iface lo inet loopback
{% for iface in system_cfg.network.interfaces %}
{% set iface_name = configuration_detected_interfaces[loop.index0] | default(iface.name | default('eth' ~ loop.index0)) %}
{% set inv_name = iface.name | default('') | string %}
{% set det_name = configuration_detected_interfaces[loop.index0] | default('eth' ~ loop.index0) %}
{% set iface_name = inv_name if inv_name | length > 0 else det_name %}
{% set has_static = (iface.ip | default('') | string | length) > 0 %}
auto {{ iface_name }}
@@ -100,7 +107,9 @@
mode: "0644"
content: |
{% for iface in system_cfg.network.interfaces %}
{% set iface_name = configuration_detected_interfaces[loop.index0] | default(iface.name | default('eth' ~ loop.index0)) %}
{% set inv_name = iface.name | default('') | string %}
{% set det_name = configuration_detected_interfaces[loop.index0] | default('eth' ~ loop.index0) %}
{% set iface_name = inv_name if inv_name | length > 0 else det_name %}
{% set has_static = (iface.ip | default('') | string | length) > 0 %}
{% if has_static %}
interface {{ iface_name }}

View File

@@ -98,7 +98,7 @@
if (system_raw.network.interfaces | default([]) | length > 0)
else (
[{
'name': 'eth0',
'name': '',
'bridge': system_raw.network.bridge | default('') | string,
'vlan': system_raw.network.vlan | default('') | string,
'ip': system_raw.network.ip | default('') | string,

View File

@@ -11,6 +11,10 @@ virtualization_libvirt_cloudinit_path: >-
{{ [virtualization_libvirt_image_dir, hostname ~ '-cloudinit.iso'] | ansible.builtin.path_join }}
virtualization_xen_disk_path: /var/lib/xen/images
virtualization_libvirt_machine_type: q35
virtualization_libvirt_ovmf_code: /usr/share/edk2/x64/OVMF_CODE.secboot.4m.fd
virtualization_libvirt_ovmf_vars: /usr/share/edk2/x64/OVMF_VARS.4m.fd
virtualization_tpm2_enabled: >-
{{
(system_cfg.luks.enabled | bool)

View File

@@ -13,7 +13,9 @@ network:
addresses:
- "{{ iface.ip }}/{{ iface.prefix }}"
{% if iface.gateway | default('') | string | length %}
gateway4: "{{ iface.gateway }}"
routes:
- to: default
via: "{{ iface.gateway }}"
{% endif %}
{% else %}
dhcp4: true

View File

@@ -4,12 +4,12 @@
{% if system_cfg.balloon is defined and system_cfg.balloon | int > 0 %}<currentMemory>{{ system_cfg.balloon | int * 1024 }}</currentMemory>{% endif %}
<vcpu placement='static'>{{ system_cfg.cpus }}</vcpu>
<os>
<type arch='x86_64' machine="pc-q35-8.0">hvm</type>
<type arch='x86_64' machine="{{ virtualization_libvirt_machine_type }}">hvm</type>
<bootmenu enable='no'/>
<boot dev='hd'/>
<boot dev='cdrom'/>
<loader readonly="yes" type="pflash">/usr/share/edk2/x64/OVMF_CODE.secboot.4m.fd</loader>
<nvram template="/usr/share/edk2/x64/OVMF_VARS.4m.fd"/>
<loader readonly="yes" type="pflash">{{ virtualization_libvirt_ovmf_code }}</loader>
<nvram template="{{ virtualization_libvirt_ovmf_vars }}"/>
</os>
<features>
<acpi/>