This seems like it should be really simple:
tasks: - name: install python packages pip: name=${item} virtualenv=~/buildbot-env with_items: [ buildbot ] - name: create buildbot master command: buildbot create-master ~/buildbot creates=~/buildbot/buildbot.tac
However, the command will not succeed unless the virtualenv's activate script is sourced first, and there doesn't seem to be provision to do that in the Ansible command module.
I've experimented with sourcing the activate script in various of .profile, .bashrc, .bash_login, etc, with no luck. Alternatively, there's the shell command, but it seems like kind of an awkward hack:
- name: create buildbot master shell: source ~/buildbot-env/bin/activate && \ buildbot create-master ~/buildbot \ creates=~/buildbot/buildbot.tac executable=/bin/bash
Is there a better way?
ansible. cfg (in the home directory) /etc/ansible/ansible. cfg.
Ansible Tower 3.0 and later uses virtualenv. Virtualenv creates isolated Python environments to avoid problems caused by conflicting dependencies and differing versions. Virtualenv works by simply creating a folder which contains all of the necessary executables and dependencies for a specific version of Python.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With