# Copy files from windows machine to linux machine using ansible

**URL:** <https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 25, 2016, 2:06pm UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259 "2016-04-25T14:06:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [April 25, 2016, 2:06pm UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/1 "2016-04-25T14:06:04Z")

</div>

I trying to copy files from a remote windows machine to my local machine(linux machine) using ansible. As fetch module works for linux to linux file transfer, is there anything similar that could enable me to fetch files from windows machine to linux machine?

---

<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:** [April 25, 2016, 2:54pm UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/2 "2016-04-25T14:54:58Z")

</div>

Fetch can also fetch from windows machines back to your ansible controller machine.

If you are fetching from \> 1 windows box don’t forget to fetch to a directory, or use something like {{ inventory\_hostname\_short }} when generating the file name.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [April 26, 2016, 4:04am UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/3 "2016-04-26T04:04:11Z")

</div>

I tried the following playbook:

---

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [April 26, 2016, 4:13am UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/4 "2016-04-26T04:13:06Z")

</div>

I did some changes and it worked. But, the whole directory is getting created on the linux machine which has the desired file.

---

<div class="post-metadata">

**Author:** ![Mick\_st\_john](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mick\_st\_john](https://forum.ansible.com/u/Mick_st_john)\
**Post date:** [April 26, 2016, 4:35am UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/5 "2016-04-26T04:35:17Z")

</div>

I used flat=yes and the issue is now resolved. Thank you!

---

<div class="post-metadata">

**Author:** ![Vigneshwar\_V](https://avatars.discourse-cdn.com/v4/letter/v/6bbea6/32.png) [@Vigneshwar\_V](https://forum.ansible.com/u/Vigneshwar_V)\
**Post date:** [November 9, 2016, 1:57am UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/6 "2016-11-09T01:57:14Z")

</div>

Can you tell me what are the changes you made

---

<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:** [November 9, 2016, 5:44pm UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/7 "2016-11-09T17:44:14Z")

</div>

This ought to do it (not tested).

Jon

---

<div class="post-metadata">

**Author:** ![Ricky\_V](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Ricky\_V](https://forum.ansible.com/u/Ricky_V)\
**Post date:** [March 14, 2018, 1:50am UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/8 "2018-03-14T01:50:52Z")

</div>

But this won’t run and there’s no error,

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [March 14, 2018, 8:39pm UTC](https://forum.ansible.com/t/copy-files-from-windows-machine-to-linux-machine-using-ansible/21259/9 "2018-03-14T20:39:37Z")

</div>

If you can share the error we may be able to help, my thoughts are the delegate\_to isn’t needed and the src path is inavlid but without any more info we can’t really help.
