I have playbook that search for file in specific folder then fetch the files to my ansible host. During the fetch process, is there a way to append the hostname of the server the file came from for each file that’s being save to my ansible host? Below is the playbook i’m currently using to to find and fetch files.
Thanks in advance.
-
hosts: all
gather_facts: yes
tasks: -
win_shell: dir /b C:\Temp
args:
executable: cmd
register: results -
debug:
var: results.stdout_lines -
name: get the files
fetch:
src: “C:/Temp/{{ item }}”
dest: /tmp/files/
flat: yes
with_items: “{{ results.stdout_lines }}”