• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in Ansible by
Q:
What is the way to access shell environment variables in Ansible?

1 Answer

0 votes
by
In Ansible, if you want to access existing variables, then you need to use the 'env' lookup plugin.

For example, you want to access the value of the Office environment on the management machine, as shown in the following command, such as:

---  

# ...  

vars:  

local_home: "{{ lookup('env','Office') }}"  

I  

{{ ansible_env.SOME_VARIABLE }}

Related questions

0 votes
asked Oct 7, 2020 in Ansible by Robindeniel
+1 vote
asked May 8, 2020 in Ansible by SakshiSharma
...