I have requirement to compare local file with remote file. Example I have a copy of standard /etc/hosts file and I need to compare that file with remote host /etc/hosts file to check the difference. If there is difference it should register it and proceed with next task. I tried various option like diff and stat but unable to get expected result.
I have requirement to compare local file with remote file. Example I have a copy of standard /etc/hosts file and I need
to compare that file with remote host /etc/hosts file to check the difference. If there is difference it should register
it and proceed with next task. I tried various option like diff and stat but unable to get expected result.
Is there any way I can execute that.
With the stat module you should be able to establish whether the files have different checksums. What did you try
exactly?
name: Verify host files md5 value
debug:
msg: “File Compare hash value of {{ remotefile.stat.checksum }} is same as {{ originalfile.stat.checksum }}.”
failed_when: remotefile.stat.checksum != originalfile.stat.checksum