# Remote lookup with remote(...)

**URL:** <https://forum.ansible.com/t/remote-lookup-with-remote/14703>\
**Category:** Ansible Project\
**Created:** [March 5, 2014, 3:03am UTC](https://forum.ansible.com/t/remote-lookup-with-remote/14703 "2014-03-05T03:03:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anatoly\_techtonik](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anatoly\_techtonik](https://forum.ansible.com/u/anatoly_techtonik)\
**Post date:** [March 5, 2014, 3:03am UTC](https://forum.ansible.com/t/remote-lookup-with-remote/14703/1 "2014-03-05T03:03:16Z")

</div>

Is it possible to implement remote lookup plugins?

Something like:

`

- name: create .hgrc if necessary  
file: path={{ hgrc }} owner={{ user }} state=touch  
when: remote(‘file\_exists’, ‘{{ hgrc }}’) == False  
`

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [March 5, 2014, 3:10am UTC](https://forum.ansible.com/t/remote-lookup-with-remote/14703/2 "2014-03-05T03:10:51Z")

</div>

they are called tasks

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [March 5, 2014, 3:11am UTC](https://forum.ansible.com/t/remote-lookup-with-remote/14703/3 "2014-03-05T03:11:54Z")

</div>

- name: check exists  
stat: path={{hgrc}}  
ignore\_errors: true  
register: hgrcfile

- name: create .hgrc if necessary  
file: path={{ hgrc }} owner={{ user }} state=touch  
when: hgrcfile.failed

---

<div class="post-metadata">

**Author:** ![anatoly\_techtonik](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anatoly\_techtonik](https://forum.ansible.com/u/anatoly_techtonik)\
**Post date:** [March 5, 2014, 10:37am UTC](https://forum.ansible.com/t/remote-lookup-with-remote/14703/4 "2014-03-05T10:37:23Z")

</div>

Thanks. Tasks are fine, but distracting from logic. Lookup plugins are  
just right for these kind of checks, but they only work on controlling  
machine, so it would be nice to have a mechanism for remote lookups, no?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [March 5, 2014, 1:23pm UTC](https://forum.ansible.com/t/remote-lookup-with-remote/14703/5 "2014-03-05T13:23:11Z")

</div>

No, lookup plugins (except when they implement iterators) are a hack to fill in some rare but important use cases, most notably sourcing file data to the authorized\_key module, and a few others. They are rarely used.

I’d use the stat module here.
