I'm attempting to install psycopg2 into a Python virtualenv with Ansible's pip
module, but I need to prepend an entry to PATH for it to build correctly (it needs to know the path to the directory containing pg_config
). I see that I can pass environment
to the pip
module, but I'm unsure of how to prepend rather than overwrite PATH
.
Here I'm attempting to prepend the path with the necessary directory, but it overwrites the virtualenv PATH
and fails:
- pip:
name: psycopg2
virtualenv: /path/to/my/venv
environment:
PATH: /usr/pgsql-9.3/bin:$PATH
If you are using Ansible 1.4 or later (which I recommend) you can access the remote
PATH
env variable: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: