# How to use lookup on the remote machine?

**URL:** <https://forum.ansible.com/t/how-to-use-lookup-on-the-remote-machine/25574>\
**Category:** Ansible Project\
**Created:** [September 22, 2017, 2:27pm UTC](https://forum.ansible.com/t/how-to-use-lookup-on-the-remote-machine/25574 "2017-09-22T14:27:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cev\_Ing](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Cev\_Ing](https://forum.ansible.com/u/Cev_Ing)\
**Post date:** [September 22, 2017, 2:27pm UTC](https://forum.ansible.com/t/how-to-use-lookup-on-the-remote-machine/25574/1 "2017-09-22T14:27:12Z")

</div>

I use the following lookup to read a password hash:

vars:  
get\_password\_hash: " file=/etc/shadow delimiter={{ ‘:’ }} col=1"

tasks:

- set\_fact:  
password: “{{ lookup(‘csvfile’, ‘nobody’ + get\_password\_hash) }}”

But this throws an permission error although I run it with “become”.

Permission denied: u’/etc/shadow’

It seems to me that the lookup is not done on the remote machine, but on the local machine.

How can I run the lookup on the remote machine?

---

<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 22, 2017, 2:31pm UTC](https://forum.ansible.com/t/how-to-use-lookup-on-the-remote-machine/25574/2 "2017-09-22T14:31:30Z")

</div>

You don't, only tasks execute on the remote, 'lookup' is a 'controller  
side function'. You can fetch/slurp the remote file or need a module  
that can query the information on the remote file.

---

<div class="post-metadata">

**Author:** ![Cev\_Ing](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Cev\_Ing](https://forum.ansible.com/u/Cev_Ing)\
**Post date:** [September 22, 2017, 2:37pm UTC](https://forum.ansible.com/t/how-to-use-lookup-on-the-remote-machine/25574/3 "2017-09-22T14:37:01Z")

</div>

Thanks.

I just found the getent module. That works fine instead.
