running mkvirtualenv using ansible

前端 未结 3 1265
悲哀的现实
悲哀的现实 2021-01-08 01:13

I am provisioning a machine using ansible. I managed to install virtualenv and virtualenvwrapper fine on the vm. However, I can\'t seem to create a virtualenv on the vm.

3条回答
  •  有刺的猬
    2021-01-08 01:36

    Additionally to @SiggyF's excellent answer, I would like to add: In case that it appears that this ansible task fails, as it happens somehow with me, you can use the failed_when feature (ansible 1.4+):

    - name: Make virtualenv
      shell: "./usr/share/virtualenvwrapper/virtualenvwrapper.sh && mkvirtualenv {{ project }} --python={{ python }} --no-site-packages"
      args:
        executable: /bin/bash
        creates: "{{ virtualenv_dir }}/{{ project }}"
      register: mkvirtualenv
      failed_when: 'mkvirtualenv.changed and "New python executable" not in mkvirtualenv.stdout'
    

提交回复
热议问题