Local setup:
ansible 1.8.2
python 2.7.1
Remote:
ansible 1.8.2
python 2.7.6
pip 1.5.4
Playbook:
---
- hosts: all
remote_user: hyc
vars:
local_base_dir: "{{ lookup('env', 'VIRTUAL_ENV') }}/../.."
remote_base_dir: "/home/hyc/hyc.org"
tasks:
- name: create virtualenv
pip: chdir="{{ remote_base_dir }}/deploy"
requirements=pip-requirements
virtualenv=python-env
When I run this playbook, my virtualenv gets created on the remote machine, but pip tries to install into the global environment, resulting in errors like:
error: could not create '/usr/local/lib/python2.7/dist-packages/django': Permission denied
It appears that the virtualenv doesn't get activated before pip starts to run. What am I doing wrong?