Host - Ubuntu 16.04
I am trying to set an environment variable for a user using:
- hosts: all remote_user: user1 tasks: - name: Adding the path in the bashrc files lineinfile: dest=/home/user1/.bashrc line='export MY_VAR=TEST' insertafter='EOF' state=present - name: Source the bashrc file shell: . /home/user1/.bashrc - debug: msg={{lookup('env','MY_VAR')}}
Unfortunately, it outputs:
TASK [debug] ******************************************************************* ok: [xxxxx.xxx] => { "msg": "" }
How can I export a variable, so the next time I run some tasks on this computer, I can use {{ lookup('env', 'MY_VAR') }} to get the value of this variable?
source share