ansible-collections / community.vmware

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

vmware_cluster_info: InvalidProperty lifecycleManaged #1047

Closed nasgust closed 4 days ago

nasgust commented 3 years ago
SUMMARY

vmware_cluster_info returns an error:

pyVmomi.VmomiSupport.InvalidProperty: (vmodl.query.InvalidProperty) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = '',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) [],
   name = 'lifecycleManaged'
}
ISSUE TYPE
COMPONENT NAME

vmware_cluster_info

ANSIBLE VERSION
ansible [core 2.11.5]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.5 (default, May 12 2021, 15:26:36) [GCC 8.3.0]
  jinja version = 3.0.1
  libyaml = True
PYVMOMI VERSION
pip show pyvmomi | grep -i -e name -e version
Name: pyvmomi
Version: 7.0.2
COLLECTION VERSION
# /root/.ansible/collections/ansible_collections
Collection       Version
---------------- -------
community.vmware 1.14.0

# /usr/local/lib/python3.9/site-packages/ansible_collections
Collection       Version
---------------- -------
community.vmware 1.14.0

VSPHERE API VERSION:

        "about_info": {
            "api_type": "VirtualCenter",
            "api_version": "6.7.3",
            "build": "18485185",
            "license_product_name": "VMware VirtualCenter Server",
            "license_product_version": "6.0",
            "locale_build": "000",
            "locale_version": "INTL",
            "os_type": "linux-x64",
            "product_full_name": "VMware vCenter Server 6.7.0 build-18485185",
            "product_line_id": "vpx",
            "product_name": "VMware vCenter Server",
            "vendor": "VMware, Inc.",
            "version": "6.7.0"
        }
CONFIGURATION
no output, using standard config.
OS / ENVIRONMENT
Debian GNU/Linux 10 (buster)
STEPS TO REPRODUCE
- name: Gather cluster info from given datacenter
  community.vmware.vmware_cluster_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: 'Datacenter'
    show_tag: True
    schema: 'vsphere'
  delegate_to: localhost
  register: cluster_info
EXPECTED RESULTS

Standard module output instead of an error.

ACTUAL RESULTS
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549 `" && echo ansible-tmp-1632319819.6722915-42-61569385109549="` echo /root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vmware_cluster_info.py
<localhost> PUT /root/.ansible/tmp/ansible-local-17tms78l0/tmpt6vbbndi TO /root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/ /root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/local/bin/python /root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py", line 100, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_cluster_info', init_globals=dict(_module_fqn='ansible_collections.community.vmware.plugins.modules.vmware_cluster_info', _modlib_path=modlib_path),
  File "/usr/local/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/local/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_cluster_info.py", line 355, in <module>
  File "/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_cluster_info.py", line 351, in main
  File "/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_cluster_info.py", line 323, in gather_cluster_info
  File "/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py", line 1914, in to_json
  File "/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py", line 1867, in _jsonify
  File "/usr/local/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/usr/local/lib/python3.9/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.9/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py", line 357, in default
    result[prop.name] = getattr(obj, prop.name)
  File "/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py", line 700, in __call__
    return self.f(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py", line 520, in _InvokeAccessor
    return self._stub.InvokeAccessor(self, info)
  File "/usr/local/lib/python3.9/site-packages/pyVmomi/StubAdapterAccessorImpl.py", line 41, in InvokeAccessor
    result = self._pc.RetrievePropertiesEx(specSet=[filterSpec],
  File "/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py", line 706, in <lambda>
    self.f(*(self.args + (obj,) + args), **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
    return self._stub.InvokeMethod(self, info, args)
  File "/usr/local/lib/python3.9/site-packages/pyVmomi/SoapAdapter.py", line 1397, in InvokeMethod
    raise obj # pylint: disable-msg=E0702
pyVmomi.VmomiSupport.InvalidProperty: (vmodl.query.InvalidProperty) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = '',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) [],
   name = 'lifecycleManaged'
}
fatal: [localhost -> localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1632319819.6722915-42-61569385109549/AnsiballZ_vmware_cluster_info.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_cluster_info', init_globals=dict(_module_fqn='ansible_collections.community.vmware.plugins.modules.vmware_cluster_info', _modlib_path=modlib_path),\n  File \"/usr/local/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/local/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/local/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_cluster_info.py\", line 355, in <module>\n  File \"/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_cluster_info.py\", line 351, in main\n  File \"/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_cluster_info.py\", line 323, in gather_cluster_info\n  File \"/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 1914, in to_json\n  File \"/tmp/ansible_community.vmware.vmware_cluster_info_payload_a7xehgp2/ansible_community.vmware.vmware_cluster_info_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py\", line 1867, in _jsonify\n  File \"/usr/local/lib/python3.9/json/__init__.py\", line 234, in dumps\n    return cls(\n  File \"/usr/local/lib/python3.9/json/encoder.py\", line 199, in encode\n    chunks = self.iterencode(o, _one_shot=True)\n  File \"/usr/local/lib/python3.9/json/encoder.py\", line 257, in iterencode\n    return _iterencode(o, 0)\n  File \"/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py\", line 357, in default\n    result[prop.name] = getattr(obj, prop.name)\n  File \"/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py\", line 700, in __call__\n    return self.f(*args, **kwargs)\n  File \"/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py\", line 520, in _InvokeAccessor\n    return self._stub.InvokeAccessor(self, info)\n  File \"/usr/local/lib/python3.9/site-packages/pyVmomi/StubAdapterAccessorImpl.py\", line 41, in InvokeAccessor\n    result = self._pc.RetrievePropertiesEx(specSet=[filterSpec],\n  File \"/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py\", line 706, in <lambda>\n    self.f(*(self.args + (obj,) + args), **kwargs)\n  File \"/usr/local/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py\", line 512, in _InvokeMethod\n    return self._stub.InvokeMethod(self, info, args)\n  File \"/usr/local/lib/python3.9/site-packages/pyVmomi/SoapAdapter.py\", line 1397, in InvokeMethod\n    raise obj # pylint: disable-msg=E0702\npyVmomi.VmomiSupport.InvalidProperty: (vmodl.query.InvalidProperty) {\n   dynamicType = <unset>,\n   dynamicProperty = (vmodl.DynamicProperty) [],\n   msg = '',\n   faultCause = <unset>,\n   faultMessage = (vmodl.LocalizableMessage) [],\n   name = 'lifecycleManaged'\n}\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
sky-joker commented 3 years ago

Thanks, @nasgust for reporting this issue.

If you want to use the vsphere schema, the properties parameter also needs.
The following is a sample playbook to get cluster name with properties parameter.

---
- hosts: localhost
  gather_facts: false
  tasks:
    - name: Gather cluster info from given datacenter
      community.vmware.vmware_cluster_info:
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        validate_certs: false
        datacenter: DC
        show_tag: true
        schema: vsphere
        properties:
          - name
      register: cluster_info

    - debug: var=cluster_info

I think it's a bug that the python errors are displayed, so I'll work on fixing it.

sky-joker commented 3 years ago

I seem that this issue probably is a bug of SDK(pyvmomi).
I found same the issue in the pyVmomi issues.

https://github.com/vmware/pyvmomi/issues/905

nasgust commented 3 years ago

Thanks @sky-joker, unfortunately pyvmomi issue is open for 3 months without any response.

sky-joker commented 3 years ago

@nasgust

Yes :(
I have tried several ways against the module to resolve this issue, but I can't resolve it yet.
What I found out while trying is that if an object has an invalid property, the property can't remove from the object. (the property read-only)
(I thought that the object can parse to JSON by removing the invalid property from the object, but...)

So the error occurs every time when parsing to JSON.

mariolenz commented 4 days ago

1.x is EOL. Anyway, this module has been moved to vmware.vmware recently: ansible-collections/vmware.vmware#80

So we'll deprecate this soon. I don't think we'll work on this, especially since there are so many open issues and PRs on current versions and modules that haven't been migrated to vmware.vmware.