I have several files on a server that I need to download from an ansible playbook
, but because the connection has good chances of interruption I would like to check their integrity after download.
I'm considering two approaches:
- Store the md5 of those files in ansible as vars
- Store the md5 of those files on the server as files with the extension .md5. Such a pair would look like:
file.extension
andfile.extension.md5
.
The first approach introduces overhead in maintaining the md5s in ansible. So everytime someone adds a new file, he needs to make sure he adds the md5 in the right place.
But as an advantage, there is a solution for this, using the built in check from get_url
action in conjunction with checksum=md5
. E.g.:
action: get_url: url=http://example.com/path/file.conf dest=/etc/foo.conf checksum=md5:66dffb5228a211e61d6d7ef4a86f5758
The second approach is more elegant and the narrows the responsibility. When someone adds a new file on the server, he will make sure to add the .md5
as well and won't even need to use the ansible playbooks.
Is there a way to use the checksum
approach to match the md5 from a file?