Ansible command from inside virtualenv?

后端 未结 5 847
不知归路
不知归路 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:41

    This is a genericized version of the wrapper method.

    venv_exec.j2:

    #!/bin/bash
    source {{ venv }}/bin/activate
    $@
    

    And then the playbook:

    tasks:
      - pip: name={{ item }} virtualenv={{ venv }}
        with_items:
          - buildbot
      - template: src=venv_exec.j2 dest={{ venv }}/exec mode=755
      - command: "{{ venv }}/exec buildbot create-master {{ buildbot_master }}"
    

提交回复
热议问题