tasks:
- name: copy hosts for validation file
copy:
src: ./templates/hosts
dest: /tmp/hosts
owner: root
group: root
mode: '0644'
backup: yes
- name: compare md5 local copy host file
stat:
path: /tmp/hosts
checksum_algorithm: md5
get_checksum: yes
register: originalfile
- name: compare md5 remote hosts file
stat:
path: /etc/hosts
checksum_algorithm: md5
get_checksum: yes
register: remotefile
- 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