diff --git a/roles/cleanup/tasks/libvirt.yml b/roles/cleanup/tasks/libvirt.yml index f447a02..01e3b8b 100644 --- a/roles/cleanup/tasks/libvirt.yml +++ b/roles/cleanup/tasks/libvirt.yml @@ -16,18 +16,6 @@ cleanup_libvirt_domain_xml: "{{ cleanup_libvirt_get_xml.get_xml }}" changed_when: false - - name: Remove boot ISO device from VM XML (target match) - community.general.xml: - xmlstring: "{{ cleanup_libvirt_domain_xml }}" - xpath: "/domain/devices/disk[target/@dev='sda']" - state: absent - register: cleanup_libvirt_xml_strip_boot - - - name: Update cleaned VM XML after removing boot ISO - ansible.builtin.set_fact: - cleanup_libvirt_domain_xml: "{{ cleanup_libvirt_xml_strip_boot.xmlstring }}" - changed_when: false - - name: Remove boot ISO device from VM XML (source match) when: boot_iso is defined and boot_iso | length > 0 community.general.xml: @@ -42,16 +30,16 @@ cleanup_libvirt_domain_xml: "{{ cleanup_libvirt_xml_strip_boot_source.xmlstring }}" changed_when: false - - name: Remove cloud-init ISO device from VM XML (target match) + - name: Remove boot ISO device from VM XML (target fallback) community.general.xml: xmlstring: "{{ cleanup_libvirt_domain_xml }}" - xpath: "/domain/devices/disk[target/@dev='sdb']" + xpath: "/domain/devices/disk[target/@dev='sda']" state: absent - register: cleanup_libvirt_xml_strip_cloudinit + register: cleanup_libvirt_xml_strip_boot - - name: Update cleaned VM XML after removing cloud-init ISO + - name: Update cleaned VM XML after removing boot ISO ansible.builtin.set_fact: - cleanup_libvirt_domain_xml: "{{ cleanup_libvirt_xml_strip_cloudinit.xmlstring }}" + cleanup_libvirt_domain_xml: "{{ cleanup_libvirt_xml_strip_boot.xmlstring }}" changed_when: false - name: Remove cloud-init ISO device from VM XML (source match) @@ -66,6 +54,18 @@ cleanup_libvirt_domain_xml: "{{ cleanup_libvirt_xml_strip_cloudinit_source.xmlstring }}" changed_when: false + - name: Remove cloud-init ISO device from VM XML (target fallback) + community.general.xml: + xmlstring: "{{ cleanup_libvirt_domain_xml }}" + xpath: "/domain/devices/disk[target/@dev='sdb']" + state: absent + register: cleanup_libvirt_xml_strip_cloudinit + + - name: Update cleaned VM XML after removing cloud-init ISO + ansible.builtin.set_fact: + cleanup_libvirt_domain_xml: "{{ cleanup_libvirt_xml_strip_cloudinit.xmlstring }}" + changed_when: false + - name: Strip XML declaration for libvirt define ansible.builtin.set_fact: cleanup_libvirt_domain_xml_clean: >-