compare results of two tasks?

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

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.