diff --git a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py index 27b0be8b474..9236113b67c 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py +++ b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py @@ -415,6 +415,9 @@ class VMwareDeployOvf: return urlunparse(url_parts.as_list()) def upload(self): + if self.params['ovf'] is None: + self.module.fail_json(msg="OVF path is required for upload operation.") + ovf_dir = os.path.dirname(self.params['ovf']) lease, import_spec = self.get_lease() @@ -436,6 +439,7 @@ class VMwareDeployOvf: msg='Failed to find deviceUrl for file %s' % file_item.path ) + vmdk_tarinfo = None if self.tar: vmdk = self.tar try: @@ -458,7 +462,6 @@ class VMwareDeployOvf: self.module.fail_json( msg='Failed to find VMDK file at %s' % vmdk ) - vmdk_tarinfo = None uploaders.append( VMDKUploader(