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
My 2 cents, i circumnavigated the problem sourcing ~/.nvm/nvm.sh
into ~/.profile
and then using sudo -iu
as suggested in another answer.
Tried on January 2018 vs Ubuntu 16.04.5
- name: Installing Nvm
shell: >
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
args:
creates: "/home/{{ ansible_user }}/.nvm/nvm.sh"
tags:
- nodejs
- name: Source nvm in ~/.profile
sudo: yes
sudo_user: "{{ ansible_user }}"
lineinfile: >
dest=~/.profile
line="source ~/.nvm/nvm.sh"
create=yes
tags:
- nodejs
register: output
- name: Installing node
command: sudo -iu {{ ansible_user }} nvm install --lts
args:
executable: /bin/bash
tags:
- nodejs