compare results of two tasks?

37 views
Skip to first unread message

Dylan Martin

unread,
Sep 3, 2014, 2:17:00 PM9/3/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Sep 4, 2014, 9:19:44 PM9/4/14
to ansible...@googlegroups.com
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.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/300f8ffc-bd14-4d41-b0fe-211b7b19f05b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages