Compare files on two different remote hosts

27 views
Skip to first unread message

jaso...@tappcg.com

unread,
Nov 30, 2017, 1:04:03 PM11/30/17
to Ansible Project
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.

Thanks for any advice. 

Kai Stian Olstad

unread,
Dec 1, 2017, 11:30:38 AM12/1/17
to ansible...@googlegroups.com
On Thursday, 30 November 2017 19.04.03 CET jaso...@tappcg.com wrote:
> 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.

Use the fetch module to get the file to the Ansible controller, then you can diff them.


> 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.

If diff is not what you need I'm out of ideas since diff print out the differences in two text files.


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages