Ansible command from inside virtualenv?

The better way is to use the full path to installed script – it will run in its virtualenv automatically:

tasks:
- name: install python packages
  pip: name={{ item }} virtualenv={{ venv }}
  with_items: [ buildbot ]
- name: create buildbot master
  command: "{{ venv }}/bin/buildbot create-master ~/buildbot
            creates=~/buildbot/buildbot.tac"

Leave a Comment