# Caching get\_url tasks

**URL:** <https://forum.ansible.com/t/caching-get-url-tasks/17546>\
**Category:** Ansible Project\
**Created:** [February 18, 2015, 9:02am UTC](https://forum.ansible.com/t/caching-get-url-tasks/17546 "2015-02-18T09:02:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Warren\_Seine1](https://avatars.discourse-cdn.com/v4/letter/w/e79b87/32.png) [@Warren\_Seine1](https://forum.ansible.com/u/Warren_Seine1)\
**Post date:** [February 18, 2015, 9:02am UTC](https://forum.ansible.com/t/caching-get-url-tasks/17546/1 "2015-02-18T09:02:00Z")

</div>

Hi,

For performance (faster first deployment), safety (in case the third party goes down), and bad connectivity (no internet) reasons, I’d like to cache downloads made with get\_url.

I know this can be done manually, but I wonder if there’s a module to do it. Would a cache=yes property make sense in the get\_url module?

Regards,  
Warren.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [February 18, 2015, 6:46pm UTC](https://forum.ansible.com/t/caching-get-url-tasks/17546/2 "2015-02-18T18:46:51Z")

</div>

Are you running get\_url as a local action? (on the ansible master rather than on your managed machines)?

I’d be tempted to try using something like varnish myself.

Jon

---

<div class="post-metadata">

**Author:** ![Warren\_Seine](https://avatars.discourse-cdn.com/v4/letter/w/ac8455/32.png) [@Warren\_Seine](https://forum.ansible.com/u/Warren_Seine)\
**Post date:** [February 24, 2015, 10:55am UTC](https://forum.ansible.com/t/caching-get-url-tasks/17546/3 "2015-02-24T10:55:44Z")

</div>

Non, I’m not use a local action. That would involve sending the data back to the managed machines at some point, basically the same as downloading the file directly on the managed machine.

Varnish could make sense, though I’m not sure if it’s not a bit overkill. I would have thought of a simple cache directory where all downloaded files would automatically go.

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [February 24, 2015, 12:27pm UTC](https://forum.ansible.com/t/caching-get-url-tasks/17546/4 "2015-02-24T12:27:51Z")

</div>

I use a pattern like this to only get the tarball when the  
'grafana\_version' var changes.  
Seems to work pretty well (NB: this happens up on the server, no local caching).

- name: download grafana tarball  
&nbsp;&nbsp;get\_url: url=[http://grafanarel.s3.amazonaws.com/grafana-\{\{grafana\_version\}\](http://grafanarel.s3.amazonaws.com/grafana-%5C%7B%5C%7Bgrafana%5C_version%5C%7D%5C)}.tar.gz  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest=/root/.grafana-{{grafana\_version}}.tar.gz

- name: extract tarball to docroot  
&nbsp;&nbsp;unarchive: src=/root/.grafana-{{grafana\_version}}.tar.gz dest=/opt/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy=no creates=/opt/grafana-{{grafana\_version}}/build.txt

---

<div class="post-metadata">

**Author:** ![Warren\_Seine](https://avatars.discourse-cdn.com/v4/letter/w/ac8455/32.png) [@Warren\_Seine](https://forum.ansible.com/u/Warren_Seine)\
**Post date:** [February 24, 2015, 4:36pm UTC](https://forum.ansible.com/t/caching-get-url-tasks/17546/5 "2015-02-24T16:36:15Z")

</div>

Ok, simple and straightforward.
