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