How to use lookup on the remote machine?

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?

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.

Thanks.

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