vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
748 stars 312 forks source link

vmware_tag_manager module error or failed to import the required Python library (vSphere Automation SDK) #250

Closed sanosir closed 3 years ago

sanosir commented 3 years ago

Environment

Steps or code snippet to reproduce

run this yaml file for python3

vars:
    ansible_python_interpreter: /usr/bin/python3
  tasks:
  - name: Add tags to a virtual machine
    vmware_tag_manager:
      hostname: "{{  VMWARE_HOST }}"
      username: "{{  VMWARE_USER }}"
      password: "{{  VMWARE_PASSWORD }}"
      validate_certs: no
      tag_names:
        - RHELServer
      object_name: DEVRHEL
      object_type: VirtualMachine
      state: add

job log here: { "exception": "Traceback (most recent call last):\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1605859409.33-134568295864586/AnsiballZ_vmware_tag_manager.py\", line 102, in \n _ansiballz_main()\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1605859409.33-134568295864586/AnsiballZ_vmware_tag_manager.py\", line 17, in _ansiballz_main\n import base64\n File \"/usr/lib64/python3.6/base64.py\", line 9, in \n import re\n File \"/usr/lib64/python3.6/re.py\", line 142, in \n class RegexFlag(enum.IntFlag):\nAttributeError: module 'enum' has no attribute 'IntFlag'\n", "_ansible_no_log": false, "_ansible_delegated_vars": { "ansible_host": "localhost" }, "module_stderr": "Traceback (most recent call last):\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1605859409.33-134568295864586/AnsiballZ_vmware_tag_manager.py\", line 102, in \n _ansiballz_main()\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1605859409.33-134568295864586/AnsiballZ_vmware_tag_manager.py\", line 17, in _ansiballz_main\n import base64\n File \"/usr/lib64/python3.6/base64.py\", line 9, in \n import re\n File \"/usr/lib64/python3.6/re.py\", line 142, in \n class RegexFlag(enum.IntFlag):\nAttributeError: module 'enum' has no attribute 'IntFlag'\n", "changed": false, "module_stdout": "", "rc": 1, "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error" }

run this yaml file for python2

  tasks:
  - name: Add tags to a virtual machine
    vmware_tag_manager:
      hostname: "{{  VMWARE_HOST }}"
      username: "{{  VMWARE_USER }}"
      password: "{{  VMWARE_PASSWORD }}"
      validate_certs: no
      tag_names:
        - RHELServer
      object_name: DEVRHEL
      object_type: VirtualMachine
      state: add

job log here: { "exception": "Traceback (most recent call last):\n File \"/tmp/ansible_vmware_tag_manager_payload_veOEcW/ansible_vmware_tag_manager_payload.zip/ansible/module_utils/vmware_rest_client.py\", line 30, in \n from com.vmware.vapi.std_client import DynamicID\nImportError: No module named com.vmware.vapi.std_client\n", "_ansible_no_log": false, "_ansible_delegated_vars": { "ansible_host": "localhost" }, "changed": false, "invocation": { "module_args": { "username": "admin", "object_type": "VirtualMachine", "protocol": "https", "hostname": "10.10.10.10", "object_name": "DEVRHEL", "state": "add", "tag_names": [ "RHELServer" ], "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "validate_certs": false } }, "msg": "Failed to import the required Python library (vSphere Automation SDK) on MASTER03's Python /usr/bin/python2. See https://code.vmware.com/web/sdk/65/vsphere-automation-python for more info. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter" }

Expected behavior

can't using vmware_tag_manager module on yaml file, when run others vmware module (tried snapshot and guest) is okay.

anusha94 commented 3 years ago

@snsiregar

Other vmware modules (snapshot and guest) are using the Automation SDK itself or pyvmomi?

anusha94 commented 3 years ago

@snsiregar Any update?

sanosir commented 3 years ago

hello @anusha94 vmware modules using pyvmomi and for right now I did not use tag_names and using annotation instead.

yqsusawq commented 2 years ago

I found same problem when I tried to tag vCenter VM´s with this module. I have SDK automation installed for python3 and I am running this job with python3 interpreter. any solution for this?

error

File "/tmp/ansible_vmware_tag_manager_payload_kej2cwnr/ansible_vmware_tag_manager_payload.zip/ansible/module_utils/vmware_rest_client.py", line 30, in from com.vmware.vapi.std_client import DynamicID ModuleNotFoundError: No module named 'com'

"Failed to import the required Python library (vSphere Automation SDK) on xxxhostxxx Python /usr/bin/python3. See https://code.vmware.com/web/sdk/65/vsphere-automation-python for more info. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"

jsalatiel commented 1 year ago

Getting the same error

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.vmware.vmware_vm_info_payload_oujsobnq/ansible_community.vmware.vmware_vm_info_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware_rest_client.py", line 32, in <module>
    from com.vmware.vapi.std_client import DynamicID
ModuleNotFoundError: No module named 'com'

when using the community.vmware.vmware_vm_info with show_tag: true