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