From 4034630625d9ee6e533f8cedb324eb674016ed28 Mon Sep 17 00:00:00 2001
From: Zubair Lutfullah Kakakhel <ZubairLK@users.noreply.github.com>
Date: Thu, 12 Oct 2017 15:32:06 +0100
Subject: [PATCH] vmware_vm_facts: Add error check for config.vm (#31629)

Add a simple check to see if vm.config exists before looking for
vm.config.hardware
---
 lib/ansible/modules/cloud/vmware/vmware_vm_facts.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py b/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py
index 1c017eb0718..4c5cacf60d8 100644
--- a/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py
+++ b/lib/ansible/modules/cloud/vmware/vmware_vm_facts.py
@@ -72,9 +72,10 @@ def get_all_virtual_machines(content):
             if _ip_address is None:
                 _ip_address = ""
         _mac_address = []
-        for dev in vm.config.hardware.device:
-            if isinstance(dev, vim.vm.device.VirtualEthernetCard):
-                _mac_address.append(dev.macAddress)
+        if vm.config is not None:
+            for dev in vm.config.hardware.device:
+                if isinstance(dev, vim.vm.device.VirtualEthernetCard):
+                    _mac_address.append(dev.macAddress)
 
         virtual_machine = {
             summary.config.name: {