diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index b68a3e31187..e85b5af8193 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -786,7 +786,12 @@ class PyVmomiHelper(PyVmomi): self.module.fail_json(msg="hardware.num_cpus attribute is mandatory for VM creation") if 'memory_mb' in self.params['hardware']: - self.configspec.memoryMB = int(self.params['hardware']['memory_mb']) + try: + self.configspec.memoryMB = int(self.params['hardware']['memory_mb']) + except ValueError: + self.module.fail_json(msg="Failed to parse hardware.memory_mb value." + " Please refer the documentation and provide" + " correct value.") if vm_obj is None or self.configspec.memoryMB != vm_obj.config.hardware.memoryMB: self.change_detected = True # memory_mb is mandatory for VM creation