diff options
Diffstat (limited to 'roles/libvirt/tasks/vm-confirm-info.yml')
| -rw-r--r-- | roles/libvirt/tasks/vm-confirm-info.yml | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/roles/libvirt/tasks/vm-confirm-info.yml b/roles/libvirt/tasks/vm-confirm-info.yml new file mode 100644 index 0000000..3121354 --- /dev/null +++ b/roles/libvirt/tasks/vm-confirm-info.yml @@ -0,0 +1,28 @@ +- name: Fetch VM information + community.libvirt.virt: + command: get_xml + name: "{{ libvirt_vm_name }}" + register: vm_info + +- name: Parse VM information + community.general.xml: + xmlstring: "{{ vm_info.get_xml }}" + xpath: "/domain/devices/disk/source" + content: attribute + register: vm_xml_output + +- name: Fail if expected disk is not found in VM XML + ansible.builtin.fail: + msg: "{{ libvirt_vm_destination }} was not found in VM disk definition {{ vm_xml_output.matches[0].source.file }}" + when: libvirt_vm_destination not in vm_xml_output.matches[0].source.file + +- name: Check filesystem for expected VM disk + ansible.builtin.stat: + path: "/{{ libvirt_vm_destination }}/{{ libvirt_vm_name }}.img" + get_checksum: false + register: vm_check_image_exists + +- name: Fail if expected VM disk is not found on destination filesystem + ansible.builtin.fail: + msg: "Expected VM disk /{{ libvirt_vm_destination }}/{{ libvirt_vm_name }}.img not found on filesystem." + when: not vm_check_image_exists.stat.exists |
