# Buggy code
def all_facts(content):
    host = find_obj(content, [vim.HostSystem], None)
    ansible_facts = {}
    ansible_facts.update(get_cpu_facts(host))
    ansible_facts.update(get_memory_facts(host))
    ansible_facts.update(get_datastore_facts(host))
    ansible_facts.update(get_network_facts(host))
    ansible_facts.update(get_system_facts(host))
    return ansible_facts


# Traceback (AttributeError)
Using module file /Users/phemmer/ansible-2.5/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_host_facts.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: phemmer
<127.0.0.1> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /Users/phemmer/.ansible/tmp/ansible-tmp-1524622902.49-163489786567676 `" &amp;&amp; echo ansible-tmp-1524622902.49-163489786567676="` echo /Users/phemmer/.ansible/tmp/ansible-tmp-1524622902.49-163489786567676 `" ) &amp;&amp; sleep 0'
<127.0.0.1> PUT /Users/phemmer/.ansible/tmp/ansible-local-98035IJ9ktm/tmpfKLeea TO /Users/phemmer/.ansible/tmp/ansible-tmp-1524622902.49-163489786567676/vmware_host_facts.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/phemmer/.ansible/tmp/ansible-tmp-1524622902.49-163489786567676/ /Users/phemmer/.ansible/tmp/ansible-tmp-1524622902.49-163489786567676/vmware_host_facts.py &amp;&amp; sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/Users/phemmer/ansible-2.5/bin/python /Users/phemmer/.ansible/tmp/ansible-tmp-1524622902.49-163489786567676/vmware_host_facts.py &amp;&amp; sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /Users/phemmer/.ansible/tmp/ansible-tmp-1524622902.49-163489786567676/ > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/ansible_t2xrmq/ansible_module_vmware_host_facts.py", line 155, in <module>
main()
File "/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/ansible_t2xrmq/ansible_module_vmware_host_facts.py", line 150, in main
data = all_facts(content)
File "/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/ansible_t2xrmq/ansible_module_vmware_host_facts.py", line 133, in all_facts
ansible_facts.update(get_cpu_facts(host))
File "/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/ansible_t2xrmq/ansible_module_vmware_host_facts.py", line 60, in get_cpu_facts
'ansible_processor': host.summary.hardware.cpuModel,
AttributeError: 'NoneType' object has no attribute 'summary'

fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/ansible_t2xrmq/ansible_module_vmware_host_facts.py\", line 155, in <module>\n    main()\n  File \"/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/ansible_t2xrmq/ansible_module_vmware_host_facts.py\", line 150, in main\n    data = all_facts(content)\n  File \"/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/ansible_t2xrmq/ansible_module_vmware_host_facts.py\", line 133, in all_facts\n    ansible_facts.update(get_cpu_facts(host))\n  File \"/var/folders/xk/jhvsfjg14zqfgtwvm0kpsy61p_63g5/T/ansible_t2xrmq/ansible_module_vmware_host_facts.py\", line 60, in get_cpu_facts\n    'ansible_processor': host.summary.hardware.cpuModel,\nAttributeError: 'NoneType' object has no attribute 'summary'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def all_facts(self):
    ansible_facts = {}
    ansible_facts.update(self.get_cpu_facts())
    ansible_facts.update(self.get_memory_facts())
    ansible_facts.update(self.get_datastore_facts())
    ansible_facts.update(self.get_network_facts())
    ansible_facts.update(self.get_system_facts())
    self.module.exit_json(changed=False, ansible_facts=ansible_facts)