How to activate virtualenv and install packages in ansible

230 views Asked by At

Disclaimer: I am not sure if this question has been asked before. Regardless,

I have an ansible playbook with few tasks. I am able to install virtualenv via the task

- name: Install virtualenv via pip
      pip:
        name: virtualenv
        executable: pip3
      become: yes
      become_user: root

But I haven't been able to activate and install the packages I require. This is what I have tried so far

- name: activate virtualenv and install requirements
      pip:
        name: setuptools
        virtualenv: "{{repository_path}}"

    - name: Install Janus server
      pip: 
        name: janus-cloud
        virtualenv: "{{repository_path}}"
        virtualenv_python: python3.5

The var here is

vars: 
    ansible_python_interpreter: /usr/bin/python3
    repository_path: /var/janus-proxy-venv

The error I am getting is

"Could not get output from /usr/local/bin/virtualenv --help: ...
... ^\nSyntaxError: invalid syntax\n"}

I am not sure what I am doing wrong here. Any leads would be greatly appreciated.

0

There are 0 answers