I need to find a way where I can compare elasticsearch template folders in given elasticsearch Data host group. Meaning if the directory is /usr/local/elasticsearch/config/templates/, I need to make sure all the files inside that directory in that ansible host group is same.
No extra template files or difference version template files. I haven't been able to figure out how to do this.
Try combining ansible with rsync dry-run using the shell module:
ansible -i production data_hosts -l '!~host1' -f 1 -m shell \
-a 'rsync --checksum --delete --dry-run -r -v host1.example.com:/usr/local/elasticsearch/config/templates/ /usr/local/elasticsearch/config/templates'
Explanation
-l limit argument: -l '!~host1'-f 1 to only run one compare at a time. Optional, but helped in my case because the directories contained large numbers of files (>10K)--dry-run to prevent rsync from actually sync'ing the directories--delete to list extraneous files in the destination directory--checksum to compare files based on checksum rather than mod-time and sizeNotes
--dry-run. Consider adding -z to compress file data during transfer, and -a for archive mode.The production inventory file would look like this:
[data_hosts]
host1.example.com
host2.example.com
host3.example.com
host4.example.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With