Q:

Ansible source virtualenvwrapper

I am trying to source virtualenvwrapper file on a remote server using Ansible.
- name: Source virtualenvwrapper
  shell: >
    . /usr/local/bin/virtualenvwrapper.sh

But I am getting Bad Substitution error. Any ideas on fixing it..??

A:

Ansible is not explicitly using /bin/sh and the shell module uses shell=True as an argument to subprocess. So probably Python subprocess uses /bin/sh and not all shell settings. There is an option for shell module named executable that can be used to specify another shell.
Try this one:
- name: Source virtualenvwrapper
  shell: >
    . /usr/local/bin/virtualenvwrapper.sh
  args:
    executable: /bin/bash

