On 09.11.2017 08:54, Dev wrote:
Hello everyone,
I have the following structure:
dir1
├── a1
│ └── one.jar
├── a2
│ └── *target*
│ └── two.jar
├── a3
│ └── subdir
│ └── *target*
│ ├── three.jar
│ ├── four.jar
│ ├── five.jar
│ └── six.war
└── a4
└── *target*
└── tmp
└── seven.jar
And I want to copy all *.jar files just under *target* directory to
single
remote directory. So the remote location should include files: two,
three, four
and five (except one, six and seven). I tried to use with_fileglob and
with_filetree but without success. Can you help me?
- name: Copy
copy:
src: "{{ item }}"
dest: ~/dir2
with_filetree: ~/dir1/../target/*.jar
with_filetree doesn't support wildcard and with_fileglobe doesn't
support recursive.
If would like to copy all the files recursive in a directory you can use
this
- name: Copy
copy:
src: "{{ item.src }}"
dest: ~/dir2/{{ item.src.split('/') | last }}
with_filetree: ~/dir1//target/
If not you would need to use find module and then copy the files with
the copy module.
--
Kai Stian Olstad
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c022859d1dd7d19b101275eb31a7b951%40olstad.com.
For more options, visit https://groups.google.com/d/optout.