# get\_url newbie question

**URL:** <https://forum.ansible.com/t/get-url-newbie-question/16300>\
**Category:** Ansible Project\
**Created:** [September 22, 2014, 3:08pm UTC](https://forum.ansible.com/t/get-url-newbie-question/16300 "2014-09-22T15:08:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Laird](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@Daniel\_Laird](https://forum.ansible.com/u/Daniel_Laird)\
**Post date:** [September 22, 2014, 3:08pm UTC](https://forum.ansible.com/t/get-url-newbie-question/16300/1 "2014-09-22T15:08:40Z")

</div>

All,

New to ansible and struggling a bit.

I want to use get\_url on a list of files. But also due to issues with the server I am downloading from I want to retry the download on failure.  
I have something like this:

- name: Download the packages  
get\_url: url=pkg\_name.tar.bz2 dest=/opt/DIR\_NAME force=yes url\_password={{ svn\_password }} url\_username={{ svn\_username }} use\_proxy=no  
register: get\_url\_result  
until: get\_url\_result.rc == 0  
retries: 5  
delay: 10  
with\_items: pkg\_list

Is this possible?  
I cant seem to get the logic right or find out what the get\_url returns in the failure case.  
I just want to try no more than 5 times for each pkg in the package list.

Cheers  
Dan

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 23, 2014, 7:19pm UTC](https://forum.ansible.com/t/get-url-newbie-question/16300/2 "2014-09-23T19:19:49Z")

</div>

A good way to check a return value is:

- debug: var=registered\_variable\_name

In this case, you should get an arrayed result.

Let us know what specific problems you are having as I have trouble parsing what “doesn’t work” means usually 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![Daniel\_Laird](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@Daniel\_Laird](https://forum.ansible.com/u/Daniel_Laird)\
**Post date:** [October 16, 2014, 1:35pm UTC](https://forum.ansible.com/t/get-url-newbie-question/16300/3 "2014-10-16T13:35:34Z")

</div>

For the benefit of all this seemed to solve it:

get\_url: url=pkg\_name.tar.bz2 dest=/opt/DIR\_NAME force=yes url\_password={{ svn\_password }} url\_username={{ svn\_username }} use\_proxy=no  
register: get\_url\_result  
until: “‘OK’ in get\_url\_result.msg”  
retries: 5  
delay: 10  
with\_items: pkg\_list

cheers  
Dan

---

<div class="post-metadata">

**Author:** ![Martin\_Palecek](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Martin\_Palecek](https://forum.ansible.com/u/Martin_Palecek)\
**Post date:** [January 2, 2015, 3:42pm UTC](https://forum.ansible.com/t/get-url-newbie-question/16300/4 "2015-01-02T15:42:25Z")

</div>

If the file is already present, then the get\_url\_result.msg does not contain ‘OK’. I had to use  
until: “‘OK’ in get\_url\_result.msg or ‘file already exists’ in get\_url\_result.msg”

---

<div class="post-metadata">

**Author:** ![Julien\_Vey](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@Julien\_Vey](https://forum.ansible.com/u/Julien_Vey)\
**Post date:** [September 15, 2016, 12:48pm UTC](https://forum.ansible.com/t/get-url-newbie-question/16300/5 "2016-09-15T12:48:44Z")

</div>

Actually, this works just fine (tested with ansible-playbook 2.1.1.0)

until: get\_url\_result | succeeded
