Ansible - accessing local environment variables

前端 未结 3 647
梦如初夏
梦如初夏 2020-12-07 23:54

I wonder if there is a way for Ansible to access local environment variables.

The documentation references accessing variable on the target machine:

         


        
3条回答
  •  不知归路
    2020-12-08 00:29

    I have a Linux vm running on osx, and for me:

    lookup('env', 'HOME') returns "/Users/Gonzalo" (the HOME variable from osx), while ansible_env.HOME returns "/root" (the HOME variable from the vm).

    Worth to mention, that ansible_env.VAR fails if the variable does not exists, while lookup('env', 'VAR') does not fail.

提交回复
热议问题