diff --git a/changelogs/fragments/54823-vmware_deploy_ovf-folder.yml b/changelogs/fragments/54823-vmware_deploy_ovf-folder.yml new file mode 100644 index 0000000000..e856eea087 --- /dev/null +++ b/changelogs/fragments/54823-vmware_deploy_ovf-folder.yml @@ -0,0 +1,2 @@ +minor_changes: + - Check return value of FindByInventoryPath API used for finding folder value (https://github.com/ansible/ansible/issues/54823). diff --git a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py index 815e7f1430..0ac652849d 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py +++ b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py @@ -370,6 +370,8 @@ class VMwareDeployOvf: if self.params['folder']: folder = self.si.searchIndex.FindByInventoryPath(self.params['folder']) + if not folder: + self.module.fail_json(msg="Unable to find the specified folder %(folder)s" % self.params) else: folder = datacenter.vmFolder