Install pyvcloud in awx venv

Hello community

I am struggling with installing pyvcloud in awx venv.

pyvcloud is the Python SDK for VMware vCloud Director: https://github.com/vmware/pyvcloud
It requires Python 3.

I was able to install pyvcloud in a awx task container based on the docker image " ansible/awx_task:1.0.6.15":

[root@awx awx]# /var/lib/awx/venv/ansible/bin/pip install pyvcloud
Requirement already satisfied: pyvcloud in /root/.local/lib/python2.7/site-packages (19.3.0)
Requirement already satisfied: PyYAML>=3.10 in ./venv/ansible/lib/python2.7/site-packages (from pyvcloud) (3.12)
Requirement already satisfied: humanfriendly>=4.8 in ./venv/ansible/lib/python2.7/site-packages (from pyvcloud) (4.8)
Requirement already satisfied: pygments>=2.2.0 in ./venv/ansible/lib/python2.7/site-packages (from pyvcloud) (2.2.0)
Requirement already satisfied: lxml>=3.4.1 in ./venv/ansible/lib/python2.7/site-packages (from pyvcloud) (4.1.1)
Requirement already satisfied: flufl.enum>=4.1.1 in /root/.local/lib/python2.7/site-packages (from pyvcloud) (4.1.1)
Requirement already satisfied: requests>=2.18.4 in ./venv/ansible/lib/python2.7/site-packages (from pyvcloud) (2.19.1)
Requirement already satisfied: monotonic; python_version == “2.6” or python_version == “2.7” or python_version == “3.0” or python_version == “3.1” or python_version == “3.2” in ./venv/ansible/lib/python2.7/site-packages (from humanfriendly>=4.8->pyvcloud) (1.4)
Requirement already satisfied: idna<2.8,>=2.5 in ./venv/ansible/lib/python2.7/site-packages (from requests>=2.18.4->pyvcloud) (2.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./venv/ansible/lib/python2.7/site-packages (from requests>=2.18.4->pyvcloud) (3.0.4)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in ./venv/ansible/lib/python2.7/site-packages (from requests>=2.18.4->pyvcloud) (1.23)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/ansible/lib/python2.7/site-packages (from requests>=2.18.4->pyvcloud) (2018.8.24)

When I run a playbook from within awx:

  • name: Create a vapp in VCloud Director
    hosts: ‘{{ hostname }}’
    connection: local
    gather_facts: False
    tasks:
  • name: Creates a new vApp in a VCA instance
    vca_vapp:
    vapp_name: Test
    state: present
    vdc_name: ‘{{ vdc_name }}’
    instance_id: ‘test’
    username: ‘{{ vcloud_user }}’
    password: ‘{{ vcloud_pass word }}’

I get this error:

FAILED! => {“changed”: false, “msg”: “python module pyvcloud is required for this module”}

Can anyone help me get this working?

Thanks in advance
Mathias

The local connection is going to still go through Ansible’s logic of coping the module to a tmp directory and invoking another python instance to run the copied module. You need to override ansible’s interpreter location see https://docs.ansible.com/ansible/2.6/reference_appendices/faq.html#how-do-i-handle-python-not-having-a-python-interpreter-at-usr-bin-python-on-a-remote-machine