title: Ansible get_url Download file only if changed
body: <p>I want to download the files from the yaml file download.yaml only if they changed.</p>
  <p>I already found this <a href="https://stackoverflow.com/a/22668463/10966928">https://stackoverflow.com/a/22668463/10966928</a> but it seems ansible still downloads the whole file, even when it is not changed</p>
  <p>task from playbook.yaml:</p>
  <pre class="lang-yaml prettyprint-override"><code>tasks:
    - name: Download File
      get_url:
        url=&quot;{{ item.value.url }}&quot;
        dest=&quot;{{ item.value.dest }}{{item.value.file }}&quot;
      loop: &quot;{{ lookup('dict', dl) }}&quot;
  </code></pre>
  <p>download.yaml:</p>
  <pre class="lang-yaml prettyprint-override"><code>dl:
    4mlinux:
      dest: /var/www/html/live/asset-mirror/releases/download/36.1-39ff9a19/
      file: vmlinuz
      url: https://github.com/netbootxyz/asset-mirror/releases/download/36.1-39ff9a19/vmlinuz
    4mlinux-antivirus:
      dest: /var/www/html/live/asset-mirror/releases/download/37.0-0.103.2-ba9e3ece/
      file: vmlinuz
      url: https://github.com/netbootxyz/asset-mirror/releases/download/37.0-0.103.2-ba9e3ece/vmlinuz
    4mlinux-bakandimg:
      dest: /var/www/html/live/asset-mirror/releases/download/36.0-262576bf/
      file: vmlinuz
      url: https://github.com/netbootxyz/asset-mirror/releases/download/36.0-262576bf/vmlinuz
  </code></pre>
  <p>Edit:<br />
  To make my question more clear.<br />
  Github does not provide hashes for releases see here <a href="https://stackoverflow.com/questions/29671303/where-to-get-md5-hashes-from-a-github-release">Where to get MD5 hashes from a GitHub release?</a></p>
  <p>I want to avoid the calculation of the checksum myself, because the <code>download.yaml</code> gets generated from another yaml file.</p>
  <p>It would be sufficient if the <code>get_url</code> module only checked the size of the file.</p>
  <p>Edit2:<br />
  Ansible still downloads the whole File.
  Here is an example Verbose Ouput:</p>
  <pre><code>ok: [127.0.0.1] =&gt; (item={'key': 'regolith-current', 'value': {'dest': '/var/www/html/live/ubuntu-squash/releases/download/1.2-0f285b8f/', 'file': 'filesystem.squashfs', 'url': 'https://github.com/netbootxyz/ubuntu-squash/releases/download/1.2-0f285b8f/filesystem.squashfs'}}) =&gt; {
  &quot;ansible_loop_var&quot;: &quot;item&quot;, 
  &quot;changed&quot;: false, 
  &quot;checksum_dest&quot;: &quot;f81cc8c2e941746ec359d93ab4ce6b14f75af225&quot;, 
  &quot;checksum_src&quot;: &quot;f81cc8c2e941746ec359d93ab4ce6b14f75af225&quot;, 
  &quot;dest&quot;: &quot;/var/www/html/live/ubuntu-squash/releases/download/1.2-0f285b8f/filesystem.squashfs&quot;, 
  &quot;elapsed&quot;: 94, 
  &quot;gid&quot;: 0, 
  &quot;group&quot;: &quot;root&quot;, 
  &quot;item&quot;: {
    &quot;key&quot;: &quot;regolith-current&quot;, 
    &quot;value&quot;: {
      &quot;dest&quot;: &quot;/var/www/html/live/ubuntu-squash/releases/download/1.2-0f285b8f/&quot;, 
      &quot;file&quot;: &quot;filesystem.squashfs&quot;, 
      &quot;url&quot;: &quot;https://github.com/netbootxyz/ubuntu-squash/releases/download/1.2-0f285b8f/filesystem.squashfs&quot;
    }
  }, 
  &quot;md5sum&quot;: &quot;285b019b7a2d91c5400b6c9991de2a60&quot;, 
  &quot;mode&quot;: &quot;0644&quot;, 
  &quot;msg&quot;: &quot;OK (2097151999 bytes)&quot;, 
  &quot;owner&quot;: &quot;root&quot;, 
  &quot;size&quot;: 2097151999, 
  &quot;src&quot;: &quot;/root/.ansible/tmp/ansible-tmp-1624984184.2966168-188394881121369/tmphilspaat&quot;, 
  &quot;state&quot;: &quot;file&quot;, 
  &quot;status_code&quot;: 200, 
  &quot;uid&quot;: 0, 
  &quot;url&quot;: &quot;https://github.com/netbootxyz/ubuntu-squash/releases/download/1.2-0f285b8f/filesystem.squashfs&quot;}
  </code></pre>
  <p>As you can see the
  <code>&quot;src&quot;: &quot;/root/.ansible/tmp/ansible-tmp-1624984184.2966168-188394881121369/tmphilspaat&quot;</code>
  and <code>&quot;elapsed&quot;: 94</code></p>