# Buggy code
def deploy(self):
    facts = {}

    if self.params["inject_ovf_env"]:
        self.inject_ovf_env()

    if self.params["power_on"]:
        task = self.entity.PowerOn()
        if self.params["wait"]:
            wait_for_task(task)
            if self.params["wait_for_ip_address"]:
                _facts = wait_for_vm_ip(self.si, self.entity)
                if not _facts:
                    self.module.fail_json(msg="Waiting for IP address timed out")
                facts.update(_facts)

    if not facts:
        facts.update(gather_vm_facts(self.si, self.entity))

    return facts


# Traceback (AttributeError)
The full traceback is:
Traceback (most recent call last):
File "/home/qiz/.ansible/tmp/ansible-tmp-1564076387.99-37546435245957/AnsiballZ_vmware_deploy_ovf.py", line 125, in <module>
_ansiballz_main()
File "/home/qiz/.ansible/tmp/ansible-tmp-1564076387.99-37546435245957/AnsiballZ_vmware_deploy_ovf.py", line 117, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/qiz/.ansible/tmp/ansible-tmp-1564076387.99-37546435245957/AnsiballZ_vmware_deploy_ovf.py", line 54, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File "/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py", line 704, in <module>
File "/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py", line 696, in main
File "/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py", line 484, in upload
File "/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py", line 389, in get_lease
File "/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py", line 359, in get_objects
File "/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/ansible_vmware_deploy_ovf_payload.zip/ansible/module_utils/vmware.py", line 186, in find_network_by_name
File "/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/ansible_vmware_deploy_ovf_payload.zip/ansible/module_utils/vmware.py", line 132, in find_object_by_name
File "/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/ansible_vmware_deploy_ovf_payload.zip/ansible/module_utils/vmware.py", line 565, in get_all_objs
AttributeError: 'vim.ServiceInstance' object has no attribute 'rootFolder'

fatal: [localhost -> localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/home/qiz/.ansible/tmp/ansible-tmp-1564076387.99-37546435245957/AnsiballZ_vmware_deploy_ovf.py\", line 125, in <module>\n    _ansiballz_main()\n  File \"/home/qiz/.ansible/tmp/ansible-tmp-1564076387.99-37546435245957/AnsiballZ_vmware_deploy_ovf.py\", line 117, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/qiz/.ansible/tmp/ansible-tmp-1564076387.99-37546435245957/AnsiballZ_vmware_deploy_ovf.py\", line 54, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py\", line 704, in <module>\n  File \"/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py\", line 696, in main\n  File \"/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py\", line 484, in upload\n  File \"/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py\", line 389, in get_lease\n  File \"/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/__main__.py\", line 359, in get_objects\n  File \"/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/ansible_vmware_deploy_ovf_payload.zip/ansible/module_utils/vmware.py\", line 186, in find_network_by_name\n  File \"/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/ansible_vmware_deploy_ovf_payload.zip/ansible/module_utils/vmware.py\", line 132, in find_object_by_name\n  File \"/tmp/ansible_vmware_deploy_ovf_payload_MVOaC0/ansible_vmware_deploy_ovf_payload.zip/ansible/module_utils/vmware.py\", line 565, in get_all_objs\nAttributeError: 'vim.ServiceInstance' object has no attribute 'rootFolder'\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}

# Fixed code
def deploy(self):
    facts = {}

    if self.params["inject_ovf_env"]:
        self.inject_ovf_env()

    if self.params["power_on"]:
        task = self.entity.PowerOn()
        if self.params["wait"]:
            wait_for_task(task)
            if self.params["wait_for_ip_address"]:
                _facts = wait_for_vm_ip(self.content, self.entity)
                if not _facts:
                    self.module.fail_json(msg="Waiting for IP address timed out")
                facts.update(_facts)

    if not facts:
        facts.update(gather_vm_facts(self.content, self.entity))

    return facts