Can not access environment variables via lookup module

24 views
Skip to first unread message

Kei Yamazaki

unread,
May 18, 2015, 7:19:06 AM5/18/15
to ansible...@googlegroups.com
I executed following playbook that uses lookup module and the "environment" settings.
But can not access environment variables.

How can I access environment variables?

---
- hosts: all
  user
: root

  vars
:
    env
:
       http_proxy
: http://proxy.example.com:8080

  tasks
:

   
- shell: "echo {{ lookup('env', 'http_proxy') }}"
      environment
: env

Output with trace logs.
       TASK: [common | shell echo ] **************************************************
       
<localhost> REMOTE_MODULE command echo #USE_SHELL
       
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1431940001.28-180226385575167 && echo $HOME/.ansible/tmp/ansible-tmp-1431940001.28-180226385575167']
       
<localhost> PUT /tmp/tmpbTOkKM TO /root/.ansible/tmp/ansible-tmp-1431940001.28-180226385575167/command
       
<localhost> EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 http_proxy=http://proxy.example.com:8080 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1431940001.28-180226385575167/command; rm -rf /root/.ansible/tmp/ansible-tmp-1431940001.28-180226385575167/ >/dev/null 2>&1']
       changed
: [localhost] => {"changed": true, "cmd": "echo", "delta": "0:00:00.002729", "end": "2015-05-18 09:06:41.343183", "rc": 0, "start": "2015-05-18 09:06:41.340454", "stderr": "", "stdout": "", "warnings": []}


Brian Coca

unread,
May 18, 2015, 7:21:57 AM5/18/15
to ansible...@googlegroups.com
soo, lookups occur on master, environment sets the execution for the
target machine. you are querying diff machine than you are setting.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages