# Compare files on two different remote hosts

**URL:** <https://forum.ansible.com/t/compare-files-on-two-different-remote-hosts/26180>\
**Category:** Ansible Developer\
**Created:** [November 30, 2017, 6:06pm UTC](https://forum.ansible.com/t/compare-files-on-two-different-remote-hosts/26180 "2017-11-30T18:06:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasontapp](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@jasontapp](https://forum.ansible.com/u/jasontapp)\
**Post date:** [November 30, 2017, 6:06pm UTC](https://forum.ansible.com/t/compare-files-on-two-different-remote-hosts/26180/1 "2017-11-30T18:06:09Z")

</div>

Does anyone know of a way to compare a file that resides on two separate hosts before and/or after a deployment? Meaning, I want to compare foo.conf on host1 against foo.conf on host2. If there are disparities, then list them in an output file.

I’ve read about a number of ways to potentially approach this (using diff command, shell module, stat module with get\_checksum param, check mode, etc.). But none of them have given exactly what I need yet.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 1, 2017, 3:37am UTC](https://forum.ansible.com/t/compare-files-on-two-different-remote-hosts/26180/2 "2017-12-01T03:37:22Z")

</div>

use slurp on 1 file then copy's 'content' option targetting the 2nd  
with the content of the first, in checkmode and with --diff.
