# compare results of two tasks?

**URL:** <https://forum.ansible.com/t/compare-results-of-two-tasks/16109>\
**Category:** Ansible Project\
**Created:** [September 3, 2014, 6:16pm UTC](https://forum.ansible.com/t/compare-results-of-two-tasks/16109 "2014-09-03T18:16:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_Martin2](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@Dylan\_Martin2](https://forum.ansible.com/u/Dylan_Martin2)\
**Post date:** [September 3, 2014, 6:16pm UTC](https://forum.ansible.com/t/compare-results-of-two-tasks/16109/1 "2014-09-03T18:16:59Z")

</div>

I’ve looked for this and haven’t found it, so if this is documented elsewhere, I do apologize.

I want to compare the md5 sums of two copies of a list of files. IE there are two locations which should have the same exact files, and I want to compare them. Not all files in the two locations need to match and I have a list of the files that should match

- stat: foo/{{ item }}  
with-items: list\_of\_files  
register: foo\_stat
- stat: bar/{{ item }}  
with-items: list\_of\_files  
register: bar\_stat
- fail: msg=“bar/{{ item }} doesn’t match foo/{{ item }}”  
with-items: list\_of\_files  
when: ???

Thanks!  
-Dylan

---

<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:** [September 5, 2014, 1:19am UTC](https://forum.ansible.com/t/compare-results-of-two-tasks/16109/2 "2014-09-05T01:19:40Z")

</div>

Yeah there’s no great way to do this really, for comparing directories with the stat module and arrays.

The stat info will contain extra info that may make this hard to compare.

You could possibly register the result of an “ls -l” type command, just showing the fields you wanted to compare, or could use the “script:” module to push a quickie script that did it.
