salt.states.file.managed takes source_hash
as an argument to verify a downloaded file. This blocks me from using file.managed
for a file on an online server I don't have control over. The file also changes regularly. My configuration looks like this.
download_stuff:
file.managed:
- name: localfile.tar.gz
- source: http://someserver.net/onlinefile.tar.gz
- source_hash: ???
I don't want to use cmd.run
with Curl
or wget
because this would always download the file, even when it's already on the local machine.
I would like the know if one of the options below is possible/exists:
- online md5 calculation service. Is there any way of getting an md5 hash of the file, using a free web service? I'm thinking of something like
http://md5service.net?url={url-to-file}
. - salt-internal conversion or workaround. Is it possible to handle this in Salt? Maybe by leaving out
source_hash
somehow? - alternative state. Is there another state in Salt for doing something like this, without losing the benefit of only downloading the file when needed?