# Behaviour of lookup in standalone playbook vs called playbook

**URL:** <https://forum.ansible.com/t/behaviour-of-lookup-in-standalone-playbook-vs-called-playbook/18944>\
**Category:** Ansible Project\
**Created:** [August 4, 2015, 11:01pm UTC](https://forum.ansible.com/t/behaviour-of-lookup-in-standalone-playbook-vs-called-playbook/18944 "2015-08-04T23:01:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Fetrow](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@David\_Fetrow](https://forum.ansible.com/u/David_Fetrow)\
**Post date:** [August 4, 2015, 11:01pm UTC](https://forum.ansible.com/t/behaviour-of-lookup-in-standalone-playbook-vs-called-playbook/18944/1 "2015-08-04T23:01:16Z")

</div>

I have playbook that, when run by itself, looks up various values on the ansible host (e.g. the repository version of a roles directory) and writes them to a log on the ansible target.

The idea being keeping a log of who ran what versions of what playbooks from where. It’s the kind of info you hope to never need but can be invaluable if you do.

Anyway; here’s a snippet.

…  
AnsibleGit: “{{ lookup(‘pipe’, ‘git log | head -1’) }}”

…

- shell: echo “{{ EpochTime }} git {{ AnsibleGit }}” \>\> {{ Log }}

When I include the playbook as one playbook among many in setting up a server (as opposed to running it standalone) the lookups run on  
the target rather than the host.

I can make something that gets that information by other means but I’d rather use lookup if I can.

Any ideas how to get lookup to always run on the host?

-david

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 4, 2015, 11:06pm UTC](https://forum.ansible.com/t/behaviour-of-lookup-in-standalone-playbook-vs-called-playbook/18944/2 "2015-08-04T23:06:18Z")

</div>

lookups always run on the machine that executes the ansible-playbook  
program (master), not sure what you mean by host or target.

The only way to run something other than on the master is through a  
task. A lookup can query an API or some other remote resource (uri  
lookup) but it runs on the master and the master must have access to  
that remote resource.
