Syntax help for "lookup"

Hi guys,

Newbie in ansible. Anybody can help me to understand the the lookup syntax below.

  • hosts: test
    roles:
  • { role: test
    data_file: {{ lookup(‘file’, ‘xyz/abc’) }}
    }

Note sure I’ll get all the content of the ‘xyz/abc’ file or just get the file path, then I can use it in the playbook:

  • name: copy template
    file: src=${data_file} dest=/tmp/abc …

Btw, I can’t find the full syntac page about the kind of “lookup” usage, anyone can help to turn on the light for me? thanks very much!

Thanks,
Dean

Using lookup(‘file’,‘xyz/abc’) would be the same as using:

with_file:

  • xyz/abc

So the above would return the content of that file. Remember, lookups are done on the controlling machine, not the target. For most cases, you can probably just use the copy/file modules if all you’re trying to do is copy a file out to remote systems.