Creating users in VCD Unsupported API version

Hi taem,

did you guys see this error ?

API version is 34

Unsupported API version. Received ‘{api_version}’ but "\n ^\nSyntaxError: invalid syntax\n

TASK [vcd : VCD USER creation] **************************************************************************************************************************************************************************************************************
task path: /data01/ansible/playbooks/roles/vcd/tasks/main.yml:1
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c ‘echo ~root && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /root/.ansible/tmp”&& mkdir /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734 && echo ansible-tmp-1595300587.72-9132-3554205710734=“echo /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734” ) && sleep 0’
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vcd_user.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-9052AXoSqK/tmpu50Pg7 TO /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/ /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘/opt/rh/python27/root/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/ > /dev/null 2>&1 && sleep 0’
The full traceback is:
Traceback (most recent call last):
File “/root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py”, line 102, in
_ansiballz_main()
File “/root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py”, line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File “/root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py”, line 40, in invoke_module
runpy.run_module(mod_name=‘ansible.modules.cloud.vmware.vcd_user’, init_globals=None, run_name=‘main’, alter_sys=True)
File “/opt/rh/python27/root/usr/lib64/python2.7/runpy.py”, line 188, in run_module
fname, loader, pkg_name)
File “/opt/rh/python27/root/usr/lib64/python2.7/runpy.py”, line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File “/opt/rh/python27/root/usr/lib64/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/tmp/ansible_vcd_user_payload_IAEjkU/ansible_vcd_user_payload.zip/ansible/modules/cloud/vmware/vcd_user.py”, line 161, in
File “/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyvcloud/vcd/org.py”, line 1845
f"Unsupported API version. Received ‘{api_version}’ but "
^
SyntaxError: invalid syntax
fatal: [localhost]: FAILED! => {
“changed”: false,
“module_stderr”: “Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py", line 102, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-tmp-1595300587.72-9132-3554205710734/AnsiballZ_vcd_user.py", line 40, in invoke_module\n runpy.run_module(mod_name=‘ansible.modules.cloud.vmware.vcd_user’, init_globals=None, run_name=‘main’, alter_sys=True)\n File "/opt/rh/python27/root/usr/lib64/python2.7/runpy.py", line 188, in run_module\n fname, loader, pkg_name)\n File "/opt/rh/python27/root/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File "/opt/rh/python27/root/usr/lib64/python2.7/runpy.py", line 72, in _run_code\n exec code in run_globals\n File "/tmp/ansible_vcd_user_payload_IAEjkU/ansible_vcd_user_payload.zip/ansible/modules/cloud/vmware/vcd_user.py", line 161, in \n File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyvcloud/vcd/org.py", line 1845\n f"Unsupported API version. Received ‘{api_version}’ but "\n ^\nSyntaxError: invalid syntax\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 1
}

PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

[root@s605141sl7vl402 ansible]#

Hi Nagesh,

Where is this vcd_user module coming from? Could you please also paste playbook?

Hi Abhijeeth,

please find my below playbook:

  • name: VCD USER creation
    vcd_user:
    user: “{{ vcd_username }}”
    password: “{{ vcd_password }}”
    host: “{{ vcd_host }}”
    org: “{{ vcd_org }}”
    api_version: “{{ vcd_api_version }}”
    verify_ssl_certs: False
    username: “test”
    userpassword: “Svvs123!”
    role_name: “Organization Administrator”
    state: “present”
    register: output

[root@s605141sl7vl402 ~]# ls -al /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/ | grep vcd
-rw-r-----. 1 root root 10158 Jul 20 22:44 vcd_catalog_item.py
-rw-r-----. 1 root root 7783 Jul 20 22:44 vcd_catalog.py
-rw-r-----. 1 root root 8162 Jul 20 22:44 vcd_disk.py
-rw-r-----. 1 root root 15602 Jul 20 22:44 vcd_external_network.py
-rw-r-----. 1 root root 9046 Jul 20 22:44 vcd_org.py
-rw-r-----. 1 root root 15797 Jul 20 22:44 vcd_org_vdc.py
-rw-r-----. 1 root root 7266 Jul 20 22:44 vcd_roles.py
-rw-r-----. 1 root root 9715 Jul 20 22:44 vcd_user.py
-rw-r-----. 1 root root 10399 Jul 20 22:44 vcd_vapp_network.py
-rw-r-----. 1 root root 16803 Jul 20 22:44 vcd_vapp.py
-rw-r-----. 1 root root 10343 Jul 20 22:44 vcd_vapp_vm_disk.py
-rw-r-----. 1 root root 9665 Jul 20 22:44 vcd_vapp_vm_nic.py
-rw-r-----. 1 root root 17924 Jul 20 22:44 vcd_vapp_vm.py
-rw-r-----. 1 root root 6485 Jul 20 22:44 vcd_vapp_vm_snapshot.py
-rw-r-----. 1 root root 20621 Jul 20 22:44 vcd_vdc_gateway.py
-rw-r-----. 1 root root 17031 Jul 20 22:44 vcd_vdc_network.py
[root@s605141sl7vl402 ~]#

Hi Nagesh,

After digging a bit, I found that these modules are coming from https://github.com/vmware/ansible-module-vcloud-director and are based upon pyvcloud.

Pyvcloud works on Python 3.6 and onwards, you are using Python 2.7. So you need to update to Python3.

Hi Abhijeet,

i have installed python 3.6 but ansible still showing 2.7, how to fix this ?

[root@s605141sl7vl402 ansible]# ansible --version
ansible 2.9.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/root/.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.17 (default, Nov 15 2019, 19:24:58) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
[root@s605141sl7vl402 ansible]# rpm -qa | grep python3
python3-setuptools-39.2.0-10.el7.noarch
python3-libs-3.6.8-13.el7.x86_64
python3-3.6.8-13.el7.x86_64
python3-pip-9.0.3-7.el7_8.noarch
[root@s605141sl7vl402 ansible]#

Hi Nagesh,

Please set this value https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python

Hi Abhi,

python isue resolved but i am gettig below error, even i am providing right password:

TASK [vcd : VCD USER creation] **************************************************************************************************************************************************************************************************************
task path: /data01/ansible/playbooks/roles/vcd/tasks/main.yml:1
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c ‘echo ~root && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /root/.ansible/tmp”&& mkdir /root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650 && echo ansible-tmp-1595532828.72-16298-259117612317650=“echo /root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650” ) && sleep 0’
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vcd_user.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-16218pbjHfY/tmpD2kGzF TO /root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/ /root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘/usr/bin/python3.6 /root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/ > /dev/null 2>&1 && sleep 0’
The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/module_utils/vcd.py”, line 45, in login
File “/usr/local/lib/python3.6/site-packages/pyvcloud/vcd/client.py”, line 986, in set_credentials
raise VcdException(‘Login failed.’)
pyvcloud.vcd.exceptions.VcdException: Login failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py”, line 102, in
_ansiballz_main()
File “/root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py”, line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File “/root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py”, line 40, in invoke_module
runpy.run_module(mod_name=‘ansible.modules.cloud.vmware.vcd_user’, init_globals=None, run_name=‘main’, alter_sys=True)
File “/usr/lib64/python3.6/runpy.py”, line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File “/usr/lib64/python3.6/runpy.py”, line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File “/usr/lib64/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/modules/cloud/vmware/vcd_user.py”, line 311, in
File “/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/modules/cloud/vmware/vcd_user.py”, line 290, in main
File “/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/modules/cloud/vmware/vcd_user.py”, line 195, in init
File “/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/module_utils/vcd.py”, line 31, in init
File “/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/module_utils/vcd.py”, line 49, in login
ansible.module_utils.vcd_errors.VCDLoginError: Login failed for user administrator to org nalab_org
fatal: [localhost]: FAILED! => {
“changed”: false,
“module_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/module_utils/vcd.py", line 45, in login\n File "/usr/local/lib/python3.6/site-packages/pyvcloud/vcd/client.py", line 986, in set_credentials\n raise VcdException(‘Login failed.’)\npyvcloud.vcd.exceptions.VcdException: Login failed.\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py", line 102, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-tmp-1595532828.72-16298-259117612317650/AnsiballZ_vcd_user.py", line 40, in invoke_module\n runpy.run_module(mod_name=‘ansible.modules.cloud.vmware.vcd_user’, init_globals=None, run_name=‘main’, alter_sys=True)\n File "/usr/lib64/python3.6/runpy.py", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/modules/cloud/vmware/vcd_user.py", line 311, in \n File "/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/modules/cloud/vmware/vcd_user.py", line 290, in main\n File "/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/modules/cloud/vmware/vcd_user.py", line 195, in init\n File "/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/module_utils/vcd.py", line 31, in init\n File "/tmp/ansible_vcd_user_payload_nm7l8qb6/ansible_vcd_user_payload.zip/ansible/module_utils/vcd.py", line 49, in login\nansible.module_utils.vcd_errors.VCDLoginError: Login failed for user administrator to org nalab_org\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 1
}

My VAR file:

vcd_host: 10.10.10.19
vcd_username: administrator
vcd_password: XXXXXXX
vcd_org: nalab_org
vcd_api_version: 34
ansible_python_interpreter: ‘/usr/bin/python3.6’

Task file:

  • name: VCD USER creation
    vcd_user:
    host: “{{ vcd_host }}”
    user: “{{ vcd_username }}”
    password: “{{ vcd_password }}”
    org: “{{ vcd_org }}”
    api_version: “{{ vcd_api_version }}”
    verify_ssl_certs: False
    username: “test”
    userpassword: “Svvs123!”
    role_name: “Organization Administrator”
    state: “present”
    register: output

Hi Team,

anyone help me on this issue

what i am missing here?

Hi Team,

anyone help me on this issue

what i am missing here?

You missed the part that is called ‘reading the error’. I did do it and it looks like your credentials are wrong.

Either way, this module is a 3rd party module, so if you run into problems best to ask the vendor or their community for support.

same password is working, i am sure this is not password issue as i can login VCD using same password, anyway let me double check on vendor support

Thanks