# fetch: does not fail when the remote file does not exist

**URL:** <https://forum.ansible.com/t/fetch-does-not-fail-when-the-remote-file-does-not-exist/12434>\
**Category:** Ansible Project\
**Created:** [February 28, 2013, 6:32pm UTC](https://forum.ansible.com/t/fetch-does-not-fail-when-the-remote-file-does-not-exist/12434 "2013-02-28T18:32:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yves\_Dorfsman](https://avatars.discourse-cdn.com/v4/letter/y/9de0a6/32.png) [@Yves\_Dorfsman](https://forum.ansible.com/u/Yves_Dorfsman)\
**Post date:** [February 28, 2013, 6:32pm UTC](https://forum.ansible.com/t/fetch-does-not-fail-when-the-remote-file-does-not-exist/12434/1 "2013-02-28T18:32:34Z")

</div>

Does this make sense?  
If I try to fetch a file that does not exist, it returns status "ok". When I run it with -vvv, I see:

"msg": "the remote file does not exist, not transferring, ignored"

Shouldn't it fail?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 28, 2013, 6:49pm UTC](https://forum.ansible.com/t/fetch-does-not-fail-when-the-remote-file-does-not-exist/12434/2 "2013-02-28T18:49:20Z")

</div>

If I recall correctly, it's actually a feature, because a particular  
logfile may not be present on a remote host, etc.

---

<div class="post-metadata">

**Author:** ![Yves\_Dorfsman](https://avatars.discourse-cdn.com/v4/letter/y/9de0a6/32.png) [@Yves\_Dorfsman](https://forum.ansible.com/u/Yves_Dorfsman)\
**Post date:** [February 28, 2013, 8:09pm UTC](https://forum.ansible.com/t/fetch-does-not-fail-when-the-remote-file-does-not-exist/12434/3 "2013-02-28T20:09:09Z")

</div>

Could we add an option to have it either way?  
I can see not failing when it's a log file, but needing it to fail when it is an important file which will be used by the next task.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 28, 2013, 8:10pm UTC](https://forum.ansible.com/t/fetch-does-not-fail-when-the-remote-file-does-not-exist/12434/4 "2013-02-28T20:10:35Z")

</div>

Sure.

I can see a fail\_on\_missing=True being an option.

We should definitely document the current behavior. It was original  
done as a very lightweight backup system.

---

<div class="post-metadata">

**Author:** ![CWS](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@CWS](https://forum.ansible.com/u/CWS)\
**Post date:** [February 28, 2013, 8:12pm UTC](https://forum.ansible.com/t/fetch-does-not-fail-when-the-remote-file-does-not-exist/12434/5 "2013-02-28T20:12:15Z")

</div>

Precede the fetch with

file: path=/path/to/file/to/be/fetched state=file
