# User environment vars in lookup plugin

**URL:** <https://forum.ansible.com/t/user-environment-vars-in-lookup-plugin/28564>\
**Category:** Ansible Project\
**Created:** [September 13, 2018, 2:26pm UTC](https://forum.ansible.com/t/user-environment-vars-in-lookup-plugin/28564 "2018-09-13T14:26:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clement\_VALENTIN1](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Clement\_VALENTIN1](https://forum.ansible.com/u/Clement_VALENTIN1)\
**Post date:** [September 13, 2018, 2:26pm UTC](https://forum.ansible.com/t/user-environment-vars-in-lookup-plugin/28564/1 "2018-09-13T14:26:31Z")

</div>

Hi,

I trying to use environment vars in lookup plugin “[hashivault](https://github.com/TerryHowe/ansible-modules-hashivault)”, but i have the feeling that lookup don’t load environment vars…

Exemple :

```auto
    - name: USER Create User
      tags: account_create_user
      environment:
        VAULT_ADDR: "{{ vault.url }}"
        VAULT_TOKEN: "{{ account_vault.root_token }}"
        VAULT_SKIP_VERIFY: true    
      vars:
        vault_path: "/test/{{ item }}"
        vault_username: "{{ lookup('hashivault', vault_path, 'username') }}"
        vault_password: "{{ lookup('hashivault', vault_path, 'password') }}"
        vault_state: "{{ lookup('hashivault', vault_path, 'state') }}"
        vault_key: "{{ lookup('hashivault', vault_path, 'key') }}"
        account_home: "/home/{{ vault_username }}"          
      with_items: "{{ account_group_fusion }}"
      user:
        name: "{{ vault_username }}"
        comment: "{{ account_description }}"
        shell: "{{ account_shell }}"
        password: "{{ vault_password|password_hash('sha512') }}"
        groups: "{{ account_groups }}"
        createhome: "{{ account_createhome }}"
        home: "{{ account_home }}"
        state: "{{ vault_state }}"
        update_password: "{{ account_reset_password }}"

```

If i exec with module shell “export VAULT\_ADDR”, remote host return the VAULT\_ADDR.  
But when use it in lookup ({{ lookup(‘pipe’,‘export VAULT\_ADDR’) }}), VAULT\_ADDR is doesn’t set…

Any idea ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 13, 2018, 2:38pm UTC](https://forum.ansible.com/t/user-environment-vars-in-lookup-plugin/28564/2 "2018-09-13T14:38:01Z")

</div>

The environment: keyword affects the task/module/action on the remote  
machine, lookups ALWAYS run locally and cannot access the  
'environment:' keyword.
