I use the stat module to read multiple files statistics from each remote server.
Thus, I’m able to get the file mode and checksum value of say 3 files on host1 and 2 files on host2.
I wish to know what is a good way to create/construct an include_vars file so that I can easily read back each file’s mode and checksum for any given server?
The information you've provided seems to contain several cases of
wheel reinvention.
Rather than helping you do that, please explain what you are REALLY
looking to achieve.
The file names in your example suggest: "configuring a web server".
In which case, a few template tasks and a handler might be all you need.
My requirement is not about configuring a webserver.
It is to maintain a check on a set of files. If the file changes by checksum or permissions I wish to trigger an alert.
Thus, my ansible will stat the file and then compare the checksum and mode that was previously stored in the include_vars file.
If they match we are good else we will trigger an alert.
Thus, I want to understand if my approach/format of storing mode and checksum information for all files on all servers good? if not please propose how should i design the include_vars files so I could read the checksum and mode of a file on a particular IP.
My requirement is not about configuring a webserver.
It is to maintain a check on a set of files. If the file changes by checksum or permissions I wish to trigger an alert.
Thus, my ansible will stat the file and then compare the checksum and mode that was previously stored in the
include_vars file.
If they match we are good else we will trigger an alert.
Thus, I want to understand if my approach/format of storing mode and checksum information for all files on all servers
good? if not please propose how should i design the include_vars files so I could read the checksum and mode of a file
on a particular IP.
Why don't use an existing checksum tool (e.g Google for linux ids checksum tools) ?