compare files, both on server

Hi,

I wish to check whether 2 files, both on server, has the same content.

tasks:
-name: Compare files, both on server side
shell: diff /home/celine/Desktop/folder/file1 /home/celine/Desktop/folder/inner/file2 >>output.txt

This fails.Fatal: all hosts have already failed --aborting

Where have i gone wrong?

Thank you.

When the 2 files have same content, the result is “changed”. But when the 2 files have different content, the error mentioned above occur.

you should try:

tasks:

  • name: compare …
    shell: …
    ignore_errors: True
    register: some_result

And then you can use “some_result” with conditionals like “when” if you like.

The key would be ignoring, but still saving, the return code.