# Ansible copy module not working recursively--or with dirs

**URL:** <https://forum.ansible.com/t/ansible-copy-module-not-working-recursively-or-with-dirs/28517>\
**Category:** Ansible Project\
**Created:** [September 6, 2018, 4:48pm UTC](https://forum.ansible.com/t/ansible-copy-module-not-working-recursively-or-with-dirs/28517 "2018-09-06T16:48:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [September 6, 2018, 4:48pm UTC](https://forum.ansible.com/t/ansible-copy-module-not-working-recursively-or-with-dirs/28517/1 "2018-09-06T16:48:57Z")

</div>

It is probably something I am doing wrong–I will be the first to admit it.

I want to copy files from my ansible server to a bunch of remote hosts. I need this to work recursively. Unfortunately it just copies the file1.txt file at the root of the src, and nothing else. Thoughts?

`  
File structure:

# tree .

.  
├── dir1  
│ ├── dir2  
│ │ └── file3.txt  
│ ├── dir3  
│ │ └── file3.txt  
│ ├── dir4  
│ │ └── file3.txt  
│ └── file2.txt  
└── file1.txt

PLAYBOOK (part of a role):

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [September 6, 2018, 4:52pm UTC](https://forum.ansible.com/t/ansible-copy-module-not-working-recursively-or-with-dirs/28517/2 "2018-09-06T16:52:54Z")

</div>

My ansible version:  
ansible-2.6.3-1.el7.noarch

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 6, 2018, 4:54pm UTC](https://forum.ansible.com/t/ansible-copy-module-not-working-recursively-or-with-dirs/28517/3 "2018-09-06T16:54:17Z")

</div>

fileglob only does files, not directories, you want filetree or just  
pipe 'find files/\*' .. or `src=files/` and avoid the loop

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [September 6, 2018, 5:18pm UTC](https://forum.ansible.com/t/ansible-copy-module-not-working-recursively-or-with-dirs/28517/4 "2018-09-06T17:18:42Z")

</div>

I thought I had tried that before, but I guess not. It appears to be copying them now with src=files, but it was dog slow. 1.6MB took about 1 minute to copy.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 6, 2018, 5:19pm UTC](https://forum.ansible.com/t/ansible-copy-module-not-working-recursively-or-with-dirs/28517/5 "2018-09-06T17:19:44Z")

</div>

for speed you want rsync or synchronize module, copy is not meant for  
bulk copying.
