# Copy multiple files in playbooks

**URL:** <https://forum.ansible.com/t/copy-multiple-files-in-playbooks/18463>\
**Category:** Ansible Project\
**Created:** [June 10, 2015, 11:11pm UTC](https://forum.ansible.com/t/copy-multiple-files-in-playbooks/18463 "2015-06-10T23:11:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![satheesh\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@satheesh\_kumar](https://forum.ansible.com/u/satheesh_kumar)\
**Post date:** [June 10, 2015, 11:11pm UTC](https://forum.ansible.com/t/copy-multiple-files-in-playbooks/18463/1 "2015-06-10T23:11:38Z")

</div>

I want to copy multiple files in playbooks, Currently i’m doing one by one

- name: Copy tomcat to target server  
copy: src=files/apache-tomcat-7.0.61.tar.gz dest=/tmp/apache-tomcat-7.0.61.tar.gz owner=root group=azureuser mode=0644  
when: ansible\_os\_family == ‘Suse’ or ansible\_os\_family == ‘RedHat’

- name: Copy file1 to target server  
copy: src=files/file1 dest=/opt/file1 owner=azureuser group=root mode=0644  
when: ansible\_os\_family == ‘Suse’ or ansible\_os\_family == ‘RedHat’

Is there a way to copy it recursively for many files with different destinations similar to below

- name: Install necessary package group  
yum: name=“{{ item }}” state=present  
with\_items:
- “libselinux-python”
- “git”
- “ksh”
- “httpd”
- “java-1.7.0-openjdk-devel”  
when: ansible\_os\_family == ‘RedHat’

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 11, 2015, 12:39am UTC](https://forum.ansible.com/t/copy-multiple-files-in-playbooks/18463/2 "2015-06-11T00:39:37Z")

</div>

many ways, you could do something like:

copy: src={{item}} dest={{item|replace('files/','')}}  
with\_fileglob: files/\*/\*

or using the pipe lookup for more complex finds.
