diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index b38ede8b88..045a063e0a 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -975,7 +975,7 @@ class PyVmomi(object): def get_vm_or_template(self, template_name=None): """ - Function to find the virtual machine or virtual machine template using name + Find the virtual machine or virtual machine template using name used for cloning purpose. Args: template_name: Name of virtual machine or virtual machine template @@ -986,6 +986,10 @@ class PyVmomi(object): template_obj = None if template_name: + template_obj = find_vm_by_id(self.content, vm_id=template_name, vm_id_type="uuid") + if template_obj: + return template_obj + objects = self.get_managed_objects_properties(vim_type=vim.VirtualMachine, properties=['name']) templates = [] diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 3d75206f52..0bb4620e6c 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -87,6 +87,7 @@ options: - If this value is not set, virtual machine is created without using a template. - If the virtual machine already exists, this parameter will be ignored. - This parameter is case sensitive. + - You can also specify template or VM UUID for identifying source. version_added 2.8. Use C(hw_product_uuid) from M(vmware_guest_facts) as UUID value. aliases: [ 'template_src' ] is_template: description: