fix: honor libvirt network config, preserve DHCP DNS with search-only NM config, and exact-match Xen VM names

This commit is contained in:
2026-02-11 14:00:20 +01:00
parent e5d2720bfe
commit 8c0716508e
4 changed files with 10 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ method=auto
{% if dns_list %} {% if dns_list %}
dns={{ dns_list | join(';') }} dns={{ dns_list | join(';') }}
{% endif %} {% endif %}
{% if dns_list or search_list %} {% if dns_list %}
ignore-auto-dns=true ignore-auto-dns=true
{% endif %} {% endif %}
{% if search_list %} {% if search_list %}

View File

@@ -101,7 +101,11 @@
when: hypervisor_type == "xen" when: hypervisor_type == "xen"
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- hostname not in system_check_xen_existing_vms.stdout | default('') - >-
not (
system_check_xen_existing_vms.stdout | default('')
is search('(?m)^' ~ (hostname | ansible.builtin.regex_escape) ~ '\\s+\\d+\\s')
)
fail_msg: | fail_msg: |
VM {{ hostname }} already exists on Xen hypervisor. VM {{ hostname }} already exists on Xen hypervisor.
To avoid data loss, the playbook will not overwrite or delete existing VMs. To avoid data loss, the playbook will not overwrite or delete existing VMs.

View File

@@ -74,4 +74,6 @@
virtualization_vm_created_in_run: true virtualization_vm_created_in_run: true
when: when:
- virtualization_xen_list_result is defined - virtualization_xen_list_result is defined
- hostname in virtualization_xen_list_result.stdout - >-
virtualization_xen_list_result.stdout | default('')
is search('(?m)^' ~ (hostname | ansible.builtin.regex_escape) ~ '\\s+\\d+\\s')

View File

@@ -48,7 +48,7 @@
{% endif %} {% endif %}
<interface type='network'> <interface type='network'>
<mac address="{{ virtualization_mac_address }}"/> <mac address="{{ virtualization_mac_address }}"/>
<source network='default'/> <source network='{{ system_cfg.network if (system_cfg.network | default('' ) | string | length) > 0 else "default" }}'/>
<model type='virtio'/> <model type='virtio'/>
</interface> </interface>
{% if virtualization_tpm2_enabled %} {% if virtualization_tpm2_enabled %}