aboutsummaryrefslogtreecommitdiff
path: root/roles/libvirt/tasks/vm-check-exists.yml
blob: 82a6d344e94f5150b08c114250a8c5c44c2d6d6c (plain)
1
2
3
4
5
6
7
8
9
- 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