Copy multiple files in playbooks

35 views
Skip to first unread message

satheesh kumar

unread,
Jun 10, 2015, 7:11:38 PM6/10/15
to ansible...@googlegroups.com
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'

Brian Coca

unread,
Jun 10, 2015, 8:39:43 PM6/10/15
to ansible...@googlegroups.com
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.
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/33474130-4cff-4c40-ba35-e9786bb3e818%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



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