I can ssh to the remote host and do a source /home/username/.bashrc - everything works fine.
However if I do:
- name: source bashrc
sudo: no
I was experiencing this same issue when trying to get virtualenvwrapper to work on an Ubuntu server. I was using Ansible like this:
- name: Make virtual environment
shell: source /home/username/.bashrc && makevirtualenv virenvname
args:
executable: /bin/bash
but the source command was not working.
Eventually I discovered that the .bashrc file has a few lines at the top of the file that prevent source from working when called by Ansible:
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
I commented out those lines in .bashrc and everything worked as expected after that.