1.

How Do I Access Shell Environment Variables?

Answer»

If you just need to access existing VARIABLES, use the ‘env’ lookup plugin.

For example, to access the value of the HOME ENVIRONMENT variable on management machine:

---

# ...

 vars:

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

If you need to set environment variables, see the Advanced Playbooks section about environments.

Ansible 1.4 will also make remote environment variables available via FACTS in the ‘ansible_env’ variable:

{{ ansible_env.SOME_VARIABLE }}

If you just need to access existing variables, use the ‘env’ lookup plugin.

For example, to access the value of the HOME environment variable on management machine:

---

# ...

 vars:

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

If you need to set environment variables, see the Advanced Playbooks section about environments.

Ansible 1.4 will also make remote environment variables available via facts in the ‘ansible_env’ variable:

{{ ansible_env.SOME_VARIABLE }}



Discussion

No Comment Found