diff options
| author | spmfox <spmfox@foxwd.com> | 2023-05-28 10:02:07 -0400 |
|---|---|---|
| committer | spmfox <spmfox@foxwd.com> | 2023-05-28 10:02:07 -0400 |
| commit | ff35c64d337a286ac2864c8403c1840e28bb23b1 (patch) | |
| tree | 36062b6fbe326b61c5abaa11721f4a909364af5a /roles/libvirt/tasks/vm-confirm-info.yml | |
| parent | efebf42259944acef6389937736995a0af8c17d5 (diff) | |
Initial commit
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 |
