# env lookup('env', '???') is there a way to list all the env variables?

**URL:** <https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [October 22, 2018, 8:06am UTC](https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842 "2018-10-22T08:06:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Louis\_Jen](https://avatars.discourse-cdn.com/v4/letter/l/b77776/32.png) [@Louis\_Jen](https://forum.ansible.com/u/Louis_Jen)\
**Post date:** [October 22, 2018, 8:06am UTC](https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842/1 "2018-10-22T08:06:14Z")

</div>

Hi all,

I thought if I put a

- command: “printenv | grep PWD”  
delegate\_to: localhost  
run\_once: ture

into awx-task container playbook, I will get the env variable PWD value which is the current project path of the ansible AWX controller.

but the value is not equal to {{ lookup(‘env’, ‘PWD’) }}, which it is “/var/lib/awx/”.

so, my question is how can I check all the ‘env’ variables of AWX and where is the ‘env’ file on AWX?

Thanks in advance.

regards,

Louis

---

<div class="post-metadata">

**Author:** ![sdmorel](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sdmorel](https://forum.ansible.com/u/sdmorel)\
**Post date:** [October 22, 2018, 8:42am UTC](https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842/2 "2018-10-22T08:42:37Z")

</div>

Hi,

You can try this:  
`

- debug:  
var: ansible\_env  
delegate\_to: localhost  
`

Have fun!

Sergio

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [October 22, 2018, 8:45am UTC](https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842/3 "2018-10-22T08:45:04Z")

</div>

Hi Louis,

You are not getting what you expect because you are using the command module, which is not processed through a shell.

Regards,  
Adrian

---

<div class="post-metadata">

**Author:** ![Louis\_Jen](https://avatars.discourse-cdn.com/v4/letter/l/b77776/32.png) [@Louis\_Jen](https://forum.ansible.com/u/Louis_Jen)\
**Post date:** [October 22, 2018, 11:32am UTC](https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842/4 "2018-10-22T11:32:30Z")

</div>

sorry, it shows the variable “ansible\_env” is not defined…

---

<div class="post-metadata">

**Author:** ![Louis\_Jen](https://avatars.discourse-cdn.com/v4/letter/l/b77776/32.png) [@Louis\_Jen](https://forum.ansible.com/u/Louis_Jen)\
**Post date:** [October 22, 2018, 11:33am UTC](https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842/5 "2018-10-22T11:33:01Z")

</div>

So… what is the correct way?

---

<div class="post-metadata">

**Author:** ![sdmorel](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sdmorel](https://forum.ansible.com/u/sdmorel)\
**Post date:** [October 22, 2018, 11:38am UTC](https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842/6 "2018-10-22T11:38:44Z")

</div>

Hello,

The **ansible\_env** variable is populated in the gather\_facts task.  
You will see it in the playbook but you won’t see it running the ansible ad-hoc command.

Regards,  
Sergio

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [October 22, 2018, 11:48am UTC](https://forum.ansible.com/t/env-lookup-env-is-there-a-way-to-list-all-the-env-variables/28842/7 "2018-10-22T11:48:15Z")

</div>

Use the shell module.
