How can I prepend to PATH while running Ansible's pip module?
Solution 1:
If you are using Ansible 1.4 or later (which I recommend) you can access the remote PATH
env variable:
- pip: name=psycopg2 virtualenv=/path/to/my/venv
environment:
PATH: /usr/pgsql-9.3/bin:{{ ansible_env.PATH }}
If instead you are interested in the PATH
env var of the local client running the Ansible scripts (instead of the targeted server), then you want to do the following:
- pip: name=psycopg2 virtualenv=/path/to/my/venv
environment:
# This only makes sense if your client and server are homogeneous, that is,
# they have the same PATHs.
PATH: /usr/pgsql-9.3/bin:{{ lookup('env', 'PATH') }}