# compare files, both on server

**URL:** <https://forum.ansible.com/t/compare-files-both-on-server/13089>\
**Category:** Ansible Project\
**Created:** [July 9, 2013, 9:13am UTC](https://forum.ansible.com/t/compare-files-both-on-server/13089 "2013-07-09T09:13:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![celine](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@celine](https://forum.ansible.com/u/celine)\
**Post date:** [July 9, 2013, 9:13am UTC](https://forum.ansible.com/t/compare-files-both-on-server/13089/1 "2013-07-09T09:13:52Z")

</div>

Hi,

I wish to check whether 2 files, both on server, has the same content.

tasks:  
-name: Compare files, both on server side  
shell: diff /home/celine/Desktop/folder/file1 /home/celine/Desktop/folder/inner/file2 \>\>output.txt

This fails.Fatal: all hosts have already failed --aborting

Where have i gone wrong?

Thank you.

---

<div class="post-metadata">

**Author:** ![celine](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@celine](https://forum.ansible.com/u/celine)\
**Post date:** [July 9, 2013, 9:40am UTC](https://forum.ansible.com/t/compare-files-both-on-server/13089/2 "2013-07-09T09:40:34Z")

</div>

When the 2 files have same content, the result is “changed”. But when the 2 files have different content, the error mentioned above occur.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 10, 2013, 1:17am UTC](https://forum.ansible.com/t/compare-files-both-on-server/13089/3 "2013-07-10T01:17:48Z")

</div>

you should try:

tasks:

- name: compare …  
shell: …  
ignore\_errors: True  
register: some\_result

And then you can use “some\_result” with conditionals like “when” if you like.

The key would be ignoring, but still saving, the return code.
