From cb1396b5be69470a98d9da2ab8c5d9ada5bd90a7 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 17 Jul 2018 09:45:39 +0530 Subject: [PATCH] VMware: vmware_vm_facts check for template config (#42354) This fix adds additional check for getting template from virtual machine before using it. Fixes: #42011 Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/cloud/vmware/vmware_vm_facts.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py b/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py index ebf66dc4fdd..5a5425f1624 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py @@ -151,9 +151,10 @@ class VmwareVmFacts(PyVmomi): } vm_type = self.module.params.get('vm_type') - if vm_type == 'vm' and vm.config.template is False: + is_template = _get_vm_prop(vm, ('config', 'template')) + if vm_type == 'vm' and not is_template: _virtual_machines.update(virtual_machine) - elif vm_type == 'template' and vm.config.template: + elif vm_type == 'template' and is_template: _virtual_machines.update(virtual_machine) elif vm_type == 'all': _virtual_machines.update(virtual_machine)