Is there a better way to run ansible inside a virtualenv on the remote machines?
So far the way I can see is to modify the .bashrc file, manually or with ansible itself.
For example:
tasks:
- name: "Enable virtualenv in .bashrc"
lineinfile: dest=.bashrc
line="source {{ PROJECT_HOME }}/venv/bin/activate"
#
# Put tasks that rely on this precondition here (?)
#
# Optionally, disable this later on
- name: "Disable virtualenv in .bashrc"
lineinfile: dest=.bashrc
line="source {{ PROJECT_HOME }}/venv/bin/activate"
state=absent
TODO: Check if the ways it could be done using ssh authorized keys: http://binblog.info/2008/10/20/openssh-going-flexible-with-forced-commands/