title: ansible - ensure content of file is the same across servers
body: <p>Using Ansible 2.9.12</p>
  <p><strong>Question:</strong> How do I configure Ansible to ensure the contents of a file is equal amongst at least 3 hosts, when the file is present at at least one host?</p>
  <p>Imagine there are 3 hosts.</p>
  <p>Host 1 does not has <code>/file.txt</code>.</p>
  <p>Host 2 has <code>/file.txt</code> with contents <code>hello</code>.</p>
  <p>Host 3 has <code>/file.txt</code> with contents <code>hello</code>.</p>
  <p>Before the play is run, I am unaware whether the file is present or not. So the file could exist on host1, or host2 or host3. But the file exists on at least one of the hosts.</p>
  <p>How would I ensure each time Ansible runs, the files across the hosts are equal. So in the end, Host 1 has the same file with the same contents as Host 2 or Host 3.</p>
  <p>I'd like this to be dynamically set, instead of specifying the host names or group names, e.g. <code>when: inventory_hostname == host1</code>.</p>
  <p>I am not expecting a check to see whether the contents of host 2 and 3 are equal</p>
  <p>I do however, want this to be setup in an idempotent fashion.</p>