Ansible copy module not working recursively--or with dirs

26 views
Skip to first unread message

John Harmon

unread,
Sep 6, 2018, 12:48:57 PM9/6/18
to Ansible Project
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):
---
# tasks file for push_files
- name: Push files to remote server
  copy
:
    src
: "{{ item }}"
    dest
: "/root/src/Collection/"
    owner
: root
    mode
: 0770
    recurse
: yes
  with_fileglob
:
   
- files/*



John Harmon

unread,
Sep 6, 2018, 12:52:54 PM9/6/18
to Ansible Project
My ansible version:
ansible-2.6.3-1.el7.noarch

Brian Coca

unread,
Sep 6, 2018, 12:54:45 PM9/6/18
to Ansible Project
fileglob only does files, not directories, you want filetree or just
pipe 'find files/*' .. or `src=files/` and avoid the loop

--
----------
Brian Coca

John Harmon

unread,
Sep 6, 2018, 1:18:42 PM9/6/18
to Ansible Project
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.

Brian Coca

unread,
Sep 6, 2018, 1:20:10 PM9/6/18
to Ansible Project
for speed you want rsync or synchronize module, copy is not meant for
bulk copying.




--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages