diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_disk.py b/lib/ansible/modules/cloud/ovirt/ovirt_disk.py index 34e968d217..5a403d9658 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_disk.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_disk.py @@ -701,10 +701,10 @@ def main(): disk = _search_by_lun(disks_service, lun.get('id')) else: disk = disks_module.search_entity(search_params=searchable_attributes(module)) - if vm_service: + if vm_service and disk: # If the VM don't exist in VMs disks, but still it's found it means it was found # for template with same name as VM, so we should force create the VM disk. - force_create = disk.id not in [a.disk.id for a in vm_service.disk_attachments_service().list()] + force_create = disk.id not in [a.disk.id for a in vm_service.disk_attachments_service().list() if a.disk] ret = None # First take care of creating the VM, if needed: