From ff35c64d337a286ac2864c8403c1840e28bb23b1 Mon Sep 17 00:00:00 2001 From: spmfox Date: Sun, 28 May 2023 10:02:07 -0400 Subject: Initial commit --- roles/libvirt/tasks/vm-check-exists.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 roles/libvirt/tasks/vm-check-exists.yml (limited to 'roles/libvirt/tasks/vm-check-exists.yml') 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 + -- cgit