copy multiple files

4,664 views
Skip to first unread message

dan...@gmail.com

unread,
Jan 17, 2013, 11:12:23 AM1/17/13
to ansible...@googlegroups.com
Is there a way to copy multiple files with a single command? The copy module doesn't seem to handle "*.conf" for example. I often want to deploy an entire folder containing multiple files and it would be tedious to have to specify each file individually. Is there a way to do this? (I know there is the git module, but in many cases that would be over-kill.)

Dan

Yves Dorfsman

unread,
Jan 17, 2013, 11:27:27 AM1/17/13
to ansible...@googlegroups.com
I have use rsync with a local_action for something similar, but yes a "copy
directory" or even an rsync module would be nice.


tasks:

- name: install prereqs for ansible
action: apt pkg=$item
with_items:
- python-yaml
- python-paramiko
- python-jinja2

- name: create /export directory
action: command mkdir -p /export/ansible creates=/export/ansible

- name: rsync (push) ansible
local_action: command rsync --delete -uaSHAXEx /export/ansible/ansible
$inventory_hostname:/export/ansible


--
Yves. http://www.SollerS.ca/
http://ipv6.SollerS.ca
http://blog.zioup.org/

Michael DeHaan

unread,
Jan 17, 2013, 12:35:53 PM1/17/13
to ansible...@googlegroups.com
There's an outstanding pull request for making copy recursive if the
source is a directory.
> --
>
>

Brian Coca

unread,
Jan 18, 2013, 8:03:55 AM1/18/13
to ansible...@googlegroups.com

You can use with_fileglob to have copy module iterate over the *.conf

Brian Coca

James Nguyễn

unread,
Jan 24, 2013, 9:54:12 PM1/24/13
to ansible...@googlegroups.com
Just to be clear, that pull request will follow folders as well if it's in the source directory?
Reply all
Reply to author
Forward
0 new messages