• name: Copy files from remote /tmp/rm/ to local machine

hosts: target_host
gather_facts: no

tasks:

  • name: Gather facts about the target host

setup:

  • name: Collect files from remote /tmp/rm/

find:
paths: /tmp/rm/
patterns: "*"
file_type: file
recurse: yes
register: remote_files

  • name: Copy collected files to local machine

copy:
src: "{{ item.path }}"
dest: /path/to/local/destination/{{ item.name }}
mode: 0644
loop: "{{ remote_files.files }}"

[file-name 000078_2025-03-27_08-03-36.txt]