# File lookup

**URL:** <https://forum.ansible.com/t/file-lookup/15934>\
**Category:** Ansible Developer\
**Created:** [August 13, 2014, 5:53pm UTC](https://forum.ansible.com/t/file-lookup/15934 "2014-08-13T17:53:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Graham\_Hay](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@Graham\_Hay](https://forum.ansible.com/u/Graham_Hay)\
**Post date:** [August 13, 2014, 5:53pm UTC](https://forum.ansible.com/t/file-lookup/15934/1 "2014-08-13T17:53:11Z")

</div>

What is the expected behaviour if a file lookup fails? I have an authorized\_key task:

- name: Key for ansible user  
authorized\_key: user=ansible key=“{{ lookup(‘file’, ‘./ansible\_key.pub’) }}”

but I moved it into a different folder, and the path is no longer correct. I would expect this to explode, but instead I got green (unchanged).

The [source](https://github.com/ansible/ansible/blob/devel/lib/ansible/runner/lookup_plugins/file.py#L57) suggests there should be an error (I’ve never seen a for…else before, you learn something new every day!), but it seems to be getting swallowed somewhere.

---

<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:** [August 14, 2014, 12:16pm UTC](https://forum.ansible.com/t/file-lookup/15934/2 "2014-08-14T12:16:06Z")

</div>

Can you file a bug for this one?

There are cases where lookups should NOT return an error when they can’t find things, but this one likely should.

The problem is in a bit of corner cases, where a lookup is used to build a path to a vars\_file or crazy things, so we’ll have to be a little careful - but those are not mainstream cases and this is.

---

<div class="post-metadata">

**Author:** ![Graham\_Hay](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@Graham\_Hay](https://forum.ansible.com/u/Graham_Hay)\
**Post date:** [August 14, 2014, 12:57pm UTC](https://forum.ansible.com/t/file-lookup/15934/3 "2014-08-14T12:57:33Z")

</div>

[Done](https://github.com/ansible/ansible/issues/8619), thanks.
