主机是Ubuntu的16.04如何永久设置环境变量?
我正在尝试设置环境变量的用户,有:
- 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')}}
不幸的是,输出:
TASK [debug] *******************************************************************
ok: [xxxxx.xxx] => {
"msg": ""
}
我怎样才能变量,以便下一次我出口在这台机器上运行一些任务我可以使用{{ lookup('env', 'MY_VAR') }}
来获取这个变量的值?