Ansible command from inside virtualenv?

后端 未结 5 886
不知归路
不知归路 2021-01-30 08:49

This seems like it should be really simple:

tasks:
- name: install python packages
  pip: name=${item} virtualenv=~/buildbot-env
  with_items: [ buildbot ]
- nam         


        
5条回答
  •  我在风中等你
    2021-01-30 09:43

    As I commented above, I create a script, say it is called buildbot.sh:

    source ~/buildbot-env/bin/activate
    buildbot create-master [and more stuff]
    

    Then run it on the remote with a task like this:

    - name: Create buildbot master
      script: buildbot.sh
    

    To me this still seems unneccessary, but it maybe cleaner than running it in a shell command. Your playbook looks cleaner at the cost of not seeing immediately what the script does.

    At least some modules do seem to use virtualenv, as both django_manage and rax_clb already have an inbuilt virtualenv parameter. It may not be such a big step for Ansible to include a command-in-virtenv sort of module.

提交回复
热议问题