# Buggy code
def inject_ovf_env(self):
    attrib = {
        "xmlns": "http://schemas.dmtf.org/ovf/environment/1",
        "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
        "xmlns:oe": "http://schemas.dmtf.org/ovf/environment/1",
        "xmlns:ve": "http://www.vmware.com/schema/ovfenv",
        "oe:id": "",
        "ve:esxId": self.entity._moId,
    }
    env = ET.Element("Environment", **attrib)

    platform = ET.SubElement(env, "PlatformSection")
    ET.SubElement(platform, "Kind").text = self.si.about.name
    ET.SubElement(platform, "Version").text = self.si.about.version
    ET.SubElement(platform, "Vendor").text = self.si.about.vendor
    ET.SubElement(platform, "Locale").text = "US"

    prop_section = ET.SubElement(env, "PropertySection")
    for key, value in self.params["properties"].items():
        params = {
            "oe:key": key,
            "oe:value": str(value) if isinstance(value, bool) else value,
        }
        ET.SubElement(prop_section, "Property", **params)

    opt = vim.option.OptionValue()
    opt.key = "guestinfo.ovfEnv"
    opt.value = '<?xml version="1.0" encoding="UTF-8"?>' + to_native(ET.tostring(env))

    config_spec = vim.vm.ConfigSpec()
    config_spec.extraConfig = [opt]

    task = self.entity.ReconfigVM_Task(config_spec)
    wait_for_task(task)


# 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 inject_ovf_env(self):
    attrib = {
        "xmlns": "http://schemas.dmtf.org/ovf/environment/1",
        "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
        "xmlns:oe": "http://schemas.dmtf.org/ovf/environment/1",
        "xmlns:ve": "http://www.vmware.com/schema/ovfenv",
        "oe:id": "",
        "ve:esxId": self.entity._moId,
    }
    env = ET.Element("Environment", **attrib)

    platform = ET.SubElement(env, "PlatformSection")
    ET.SubElement(platform, "Kind").text = self.content.about.name
    ET.SubElement(platform, "Version").text = self.content.about.version
    ET.SubElement(platform, "Vendor").text = self.content.about.vendor
    ET.SubElement(platform, "Locale").text = "US"

    prop_section = ET.SubElement(env, "PropertySection")
    for key, value in self.params["properties"].items():
        params = {
            "oe:key": key,
            "oe:value": str(value) if isinstance(value, bool) else value,
        }
        ET.SubElement(prop_section, "Property", **params)

    opt = vim.option.OptionValue()
    opt.key = "guestinfo.ovfEnv"
    opt.value = '<?xml version="1.0" encoding="UTF-8"?>' + to_native(ET.tostring(env))

    config_spec = vim.vm.ConfigSpec()
    config_spec.extraConfig = [opt]

    task = self.entity.ReconfigVM_Task(config_spec)
    wait_for_task(task)