ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
351 stars 337 forks source link

vmware_guest_find failed with fatal errors #1282

Open sathe06 opened 2 years ago

sathe06 commented 2 years ago
SUMMARY

We were using vmware_guest_find module to find vm details Scenario: Daily more than 200 vm's this playbook will run. vm_name output value will run with lower/upper sometimes without that. Out of 20 server in a row 4-5 got failed with below error message. If we re-run it again its working as expected. playbook:

- name: check virtual machines details
   vmware_guest_find:
          hostname: "{{ vcenter_host }}"
          username: "{{ vcenter_username }}"
          password: "{{ vcenter_password }}"
          validate_certs: False
          name: "{{ vm_name | lower }}"

we have tried using name as upper-case and without using anything error message:

{
        "changed": false, 
        "exception": "Traceback (most recent call last):\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 102, in <module>\\n    _ansiballz_main()\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 94, in _ansiballz_main\\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 40, in invoke_module\\n    runpy.run_module(mod_name='ansible.modules.cloud.vmware.vmware_guest_find', init_globals=None, run_name='__main__', alter_sys=True)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 176, in run_module\\n    fname, loader, pkg_name)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 82, in _run_module_code\\n    mod_name, mod_fname, mod_loader, pkg_name)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 72, in _run_code\\n    exec code in run_globals\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 160, in <module>\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 146, in main\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 120, in getvm_folder_paths\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 700, in __call__\\n    return self.f(*args, **kwargs)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 520, in _InvokeAccessor\\n    return self._stub.InvokeAccessor(self, info)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/StubAdapterAccessorImpl.py\\", line 42, in InvokeAccessor\\n    options=self._pcType.RetrieveOptions(maxObjects=1))\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 706, in <lambda>\\n    self.f(*(self.args + (obj,) + args), **kwargs)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 512, in _InvokeMethod\\n    return self._stub.InvokeMethod(self, info, args)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py\\", line 1397, in InvokeMethod\\n    raise obj # pylint: disable-msg=E0702\\npyVmomi.VmomiSupport.ManagedObjectNotFound: (vmodl.fault.ManagedObjectNotFound) {\\n   dynamicType = <unset>,\\n   dynamicProperty = (vmodl.DynamicProperty) [],\\n   msg = \\"The object 'vim.VirtualMachine:vm-2969' has already been deleted or has not been completely created\\",\\n   faultCause = <unset>,\\n   faultMessage = (vmodl.LocalizableMessage) [],\\n   obj = 'vim.VirtualMachine:vm-2969'\\n}\\n", 
        "failed": true, 
        "module_stderr": "Traceback (most recent call last):\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 102, in <module>\\n    _ansiballz_main()\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 94, in _ansiballz_main\\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 40, in invoke_module\\n    runpy.run_module(mod_name='ansible.modules.cloud.vmware.vmware_guest_find', init_globals=None, run_name='__main__', alter_sys=True)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 176, in run_module\\n    fname, loader, pkg_name)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 82, in _run_module_code\\n    mod_name, mod_fname, mod_loader, pkg_name)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 72, in _run_code\\n    exec code in run_globals\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 160, in <module>\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 146, in main\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 120, in getvm_folder_paths\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 700, in __call__\\n    return self.f(*args, **kwargs)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 520, in _InvokeAccessor\\n    return self._stub.InvokeAccessor(self, info)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/StubAdapterAccessorImpl.py\\", line 42, in InvokeAccessor\\n    options=self._pcType.RetrieveOptions(maxObjects=1))\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 706, in <lambda>\\n    self.f(*(self.args + (obj,) + args), **kwargs)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 512, in _InvokeMethod\\n    return self._stub.InvokeMethod(self, info, args)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py\\", line 1397, in InvokeMethod\\n    raise obj # pylint: disable-msg=E0702\\npyVmomi.VmomiSupport.ManagedObjectNotFound: (vmodl.fault.ManagedObjectNotFound) {\\n   dynamicType = <unset>,\\n   dynamicProperty = (vmodl.DynamicProperty) [],\\n   msg = \\"The object 'vim.VirtualMachine:vm-2969' has already been deleted or has not been completely created\\",\\n   faultCause = <unset>,\\n   faultMessage = (vmodl.LocalizableMessage) [],\\n   obj = 'vim.VirtualMachine:vm-2969'\\n}\\n", 
        "module_stdout": "", 
        "msg": "MODULE FAILURE\\nSee stdout/stderr for the exact error", 
        "rc": 1
    }
ISSUE TYPE
COMPONENT NAME

vmware_guest_find

ANSIBLE VERSION
$ ansible --version

ansible 2.9.15
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/users/w661672a/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.18 (default, Sep 30 2020, 13:13:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-37)]
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT

Red Hat Enterprise Linux Server release 7.7 (Maipo)

STEPS TO REPRODUCE
- name: check virtual machines details
  vmware_guest_find:
          hostname: "{{ vcenter_host }}"
          username: "{{ vcenter_username }}"
          password: "{{ vcenter_password }}"
          validate_certs: False
          name: "{{ vm_name | lower }}"
EXPECTED RESULTS

{"changed": false, "folders": ["/xxxxxx/vm/Discovered virtual machine"]}

ACTUAL RESULTS
{
        "changed": false, 
        "exception": "Traceback (most recent call last):\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 102, in <module>\\n    _ansiballz_main()\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 94, in _ansiballz_main\\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 40, in invoke_module\\n    runpy.run_module(mod_name='ansible.modules.cloud.vmware.vmware_guest_find', init_globals=None, run_name='__main__', alter_sys=True)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 176, in run_module\\n    fname, loader, pkg_name)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 82, in _run_module_code\\n    mod_name, mod_fname, mod_loader, pkg_name)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 72, in _run_code\\n    exec code in run_globals\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 160, in <module>\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 146, in main\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 120, in getvm_folder_paths\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 700, in __call__\\n    return self.f(*args, **kwargs)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 520, in _InvokeAccessor\\n    return self._stub.InvokeAccessor(self, info)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/StubAdapterAccessorImpl.py\\", line 42, in InvokeAccessor\\n    options=self._pcType.RetrieveOptions(maxObjects=1))\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 706, in <lambda>\\n    self.f(*(self.args + (obj,) + args), **kwargs)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 512, in _InvokeMethod\\n    return self._stub.InvokeMethod(self, info, args)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py\\", line 1397, in InvokeMethod\\n    raise obj # pylint: disable-msg=E0702\\npyVmomi.VmomiSupport.ManagedObjectNotFound: (vmodl.fault.ManagedObjectNotFound) {\\n   dynamicType = <unset>,\\n   dynamicProperty = (vmodl.DynamicProperty) [],\\n   msg = \\"The object 'vim.VirtualMachine:vm-2969' has already been deleted or has not been completely created\\",\\n   faultCause = <unset>,\\n   faultMessage = (vmodl.LocalizableMessage) [],\\n   obj = 'vim.VirtualMachine:vm-2969'\\n}\\n", 
        "failed": true, 
        "module_stderr": "Traceback (most recent call last):\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 102, in <module>\\n    _ansiballz_main()\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 94, in _ansiballz_main\\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\\n  File \\"/var/lib/awx/.ansible/tmp/ansible-tmp-1649243082.37-19141-217606461130897/AnsiballZ_vmware_guest_find.py\\", line 40, in invoke_module\\n    runpy.run_module(mod_name='ansible.modules.cloud.vmware.vmware_guest_find', init_globals=None, run_name='__main__', alter_sys=True)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 176, in run_module\\n    fname, loader, pkg_name)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 82, in _run_module_code\\n    mod_name, mod_fname, mod_loader, pkg_name)\\n  File \\"/usr/lib64/python2.7/runpy.py\\", line 72, in _run_code\\n    exec code in run_globals\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 160, in <module>\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 146, in main\\n  File \\"/tmp/ansible_vmware_guest_find_payload_TAJDty/ansible_vmware_guest_find_payload.zip/ansible/modules/cloud/vmware/vmware_guest_find.py\\", line 120, in getvm_folder_paths\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 700, in __call__\\n    return self.f(*args, **kwargs)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 520, in _InvokeAccessor\\n    return self._stub.InvokeAccessor(self, info)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/StubAdapterAccessorImpl.py\\", line 42, in InvokeAccessor\\n    options=self._pcType.RetrieveOptions(maxObjects=1))\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 706, in <lambda>\\n    self.f(*(self.args + (obj,) + args), **kwargs)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\\", line 512, in _InvokeMethod\\n    return self._stub.InvokeMethod(self, info, args)\\n  File \\"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py\\", line 1397, in InvokeMethod\\n    raise obj # pylint: disable-msg=E0702\\npyVmomi.VmomiSupport.ManagedObjectNotFound: (vmodl.fault.ManagedObjectNotFound) {\\n   dynamicType = <unset>,\\n   dynamicProperty = (vmodl.DynamicProperty) [],\\n   msg = \\"The object 'vim.VirtualMachine:vm-2969' has already been deleted or has not been completely created\\",\\n   faultCause = <unset>,\\n   faultMessage = (vmodl.LocalizableMessage) [],\\n   obj = 'vim.VirtualMachine:vm-2969'\\n}\\n", 
        "module_stdout": "", 
        "msg": "MODULE FAILURE\\nSee stdout/stderr for the exact error", 
        "rc": 1
    }
mariolenz commented 2 years ago

ansible 2.9.15 config file = /etc/ansible/ansible.cfg configured module search path = [u'/users/w661672a/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.18 (default, Sep 30 2020, 13:13:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-37)]


##### COLLECTION VERSION

This looks like you use vmware_guest_find that's part of 2.9.15 and not this collection. To tell you the truth, I don't think anyone will work on this. 2.9 (and 2.10, too) will reach EOL next month AFAIK. And since we're a bit short-handed at the moment, I don't think anyone will invest time on fixing this.

Would it be possible for you to test this with a more current Ansible release? Ideally, ansible-core 2.11+ with community 2.2.0 or Ansible 6.0.0 alpha 1 (which I think will be released today or tomorrow).