Execution
Date 23 May 2025 11:01:56 +0100
Duration 00:01:02.48
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.11
ara 1.7.2 / 1.7.2
Python 3.10.10
Summary
25 Hosts
3 Tasks
72 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/fetch-files-from-hosts.yaml

---
- name: Fetch the panelinis
  hosts: all
  gather_facts: false
  vars:
    remote_dir: /root/panelinis
    local_base_dir: "fetched_files"
  tasks:
    - name: Create local directory for this host
      delegate_to: localhost
      run_once: true
      ansible.builtin.file:
        path: "{{ local_base_dir }}/{{ inventory_hostname }}"
        state: directory
        mode: '0755'
    - name: Find files in remote directory
      ansible.builtin.find:
        paths: "{{ remote_dir }}"
        file_type: file
      register: remote_files
    - name: Fetch each found file to the local host-specific directory
      ansible.builtin.fetch:
        src: "{{ item.path }}"
        dest: "{{ local_base_dir }}/{{ inventory_hostname }}/{{ item.path | basename }}"
        flat: true
      loop: "{{ remote_files.files }}"