I can ssh to the remote host and do a source /home/username/.bashrc - everything works fine. However if I do:
source /home/username/.bashrc
- name: source bashrc sudo: no
I found become as best solution:
- name: Source .bashrc shell: . .bashrc become: true
You can change the user by adding (default: root):
- name: Source .bashrc shell: . .bashrc become: true become-user: {your_remote_user}
More info here: Ansible become