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

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

Hi,

You can try this:
`

  • debug:
    var: ansible_env
    delegate_to: localhost
    `

Have fun!

Sergio

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

sorry, it shows the variable “ansible_env” is not defined…

So… what is the correct way?

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

Use the shell module.