diff options
Diffstat (limited to 'roles/libvirt/tasks/vm-check-exists.yml')
| -rw-r--r-- | roles/libvirt/tasks/vm-check-exists.yml | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/roles/libvirt/tasks/vm-check-exists.yml b/roles/libvirt/tasks/vm-check-exists.yml new file mode 100644 index 0000000..c6adf31 --- /dev/null +++ b/roles/libvirt/tasks/vm-check-exists.yml @@ -0,0 +1,10 @@ +- name: Fetch list of all VMs + community.libvirt.virt: + command: list_vms + register: vms_list + +- name: Fail if VM does not exist + ansible.builtin.fail: + msg: "VM {{ libvirt_vm_name }} does not exist." + when: libvirt_vm_name | string not in vms_list.list_vms + |
