# Fetch from URL to local machine and then copy to remote

**URL:** <https://forum.ansible.com/t/fetch-from-url-to-local-machine-and-then-copy-to-remote/14519>\
**Category:** Ansible Project\
**Created:** [February 7, 2014, 3:55pm UTC](https://forum.ansible.com/t/fetch-from-url-to-local-machine-and-then-copy-to-remote/14519 "2014-02-07T15:55:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Johren](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Martin\_Johren](https://forum.ansible.com/u/Martin_Johren)\
**Post date:** [February 7, 2014, 3:55pm UTC](https://forum.ansible.com/t/fetch-from-url-to-local-machine-and-then-copy-to-remote/14519/1 "2014-02-07T15:55:55Z")

</div>

Hi,

I am looking for a way to download a file to the local machine where ansible was started and then copy that file to the remote server. Background: due to security issues we cannot directly download the file from our nexus on the remote server so we need to download it first to the local machine and the use that file in ansible. Currently we start a small shell script before using ansible for this deployment but this is not very nice 😉 Is there something which can be used currently or do we have to write an own module?

Thanks,

Martin

---

<div class="post-metadata">

**Author:** ![Romeo\_Theriault](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Romeo\_Theriault](https://forum.ansible.com/u/Romeo_Theriault)\
**Post date:** [February 7, 2014, 5:03pm UTC](https://forum.ansible.com/t/fetch-from-url-to-local-machine-and-then-copy-to-remote/14519/2 "2014-02-07T17:03:42Z")

</div>

Sounds like you can use the 'get\_url' module with 'delegate\_to:  
127.0.0.1' to download the file locally, then use the 'copy' module to  
copy it to the remote host.

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [February 7, 2014, 5:05pm UTC](https://forum.ansible.com/t/fetch-from-url-to-local-machine-and-then-copy-to-remote/14519/3 "2014-02-07T17:05:49Z")

</div>

> I am looking for a way to download a file to the local machine where  
> ansible was started and then copy that file to the remote server.

action: get\_url ...  
action: copy ...

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [February 7, 2014, 6:26pm UTC](https://forum.ansible.com/t/fetch-from-url-to-local-machine-and-then-copy-to-remote/14519/4 "2014-02-07T18:26:09Z")

</div>

​That's exactly what we do. Though depending on which url you use to  
download from nexus, you might want to choose the uri module to do the  
download. ​The latter one allows you to register the exact filename, when  
you use Nexus' rest api, which does a redirect to the exact file location.

Serge

---

<div class="post-metadata">

**Author:** ![Martin\_Johren](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Martin\_Johren](https://forum.ansible.com/u/Martin_Johren)\
**Post date:** [February 15, 2014, 1:22pm UTC](https://forum.ansible.com/t/fetch-from-url-to-local-machine-and-then-copy-to-remote/14519/5 "2014-02-15T13:22:23Z")

</div>

thx guys. will try that

---

<div class="post-metadata">

**Author:** ![Martin\_Johren](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Martin\_Johren](https://forum.ansible.com/u/Martin_Johren)\
**Post date:** [February 15, 2014, 1:54pm UTC](https://forum.ansible.com/t/fetch-from-url-to-local-machine-and-then-copy-to-remote/14519/6 "2014-02-15T13:54:41Z")

</div>

i finally used something like that:

- name: download locally  
local\_action: get\_url dest

works fine.

Thanks to all
