# How to copy a file from control machine to the host where task is running

**URL:** <https://forum.ansible.com/t/how-to-copy-a-file-from-control-machine-to-the-host-where-task-is-running/20758>\
**Category:** Ansible Project\
**Created:** [March 3, 2016, 9:34am UTC](https://forum.ansible.com/t/how-to-copy-a-file-from-control-machine-to-the-host-where-task-is-running/20758 "2016-03-03T09:34:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepa\_Yr](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@Deepa\_Yr](https://forum.ansible.com/u/Deepa_Yr)\
**Post date:** [March 3, 2016, 9:34am UTC](https://forum.ansible.com/t/how-to-copy-a-file-from-control-machine-to-the-host-where-task-is-running/20758/1 "2016-03-03T09:34:12Z")

</div>

I have few files in control machine ie host1.  
My playbook/tasks are running on host2.  
I need to copy the files from host1 to host2.

Please let me know how it can be done

---

<div class="post-metadata">

**Author:** ![Deepa\_Yr](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@Deepa\_Yr](https://forum.ansible.com/u/Deepa_Yr)\
**Post date:** [March 7, 2016, 5:20am UTC](https://forum.ansible.com/t/how-to-copy-a-file-from-control-machine-to-the-host-where-task-is-running/20758/2 "2016-03-07T05:20:09Z")

</div>

Any help on this ?

---

<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:** [March 7, 2016, 2:59pm UTC](https://forum.ansible.com/t/how-to-copy-a-file-from-control-machine-to-the-host-where-task-is-running/20758/3 "2016-03-07T14:59:42Z")

</div>

Try the copy module:

[http://docs.ansible.com/ansible/copy\_module.html](http://docs.ansible.com/ansible/copy_module.html)

---

<div class="post-metadata">

**Author:** ![Dan\_Lang](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@Dan\_Lang](https://forum.ansible.com/u/Dan_Lang)\
**Post date:** [March 7, 2016, 4:57pm UTC](https://forum.ansible.com/t/how-to-copy-a-file-from-control-machine-to-the-host-where-task-is-running/20758/4 "2016-03-07T16:57:11Z")

</div>

Besides the copy module, there is the synchronize module for syncing many files in a directory, [http://docs.ansible.com/ansible/synchronize\_module.html](http://docs.ansible.com/ansible/synchronize_module.html). Feel free to review each of the modules that help with managing files, [http://docs.ansible.com/ansible/list\_of\_files\_modules.html](http://docs.ansible.com/ansible/list_of_files_modules.html)
