ansible_cache/home_linux/get_logs.yml
2024-12-27 12:47:45 +00:00

23 lines
483 B
YAML
Executable File

---
- name: Copy the contents of the "/var/log" folder to the Ansible controller
hosts: all
roles:
- common
become: yes
gather_facts: no
tasks:
- name: Generate the list of files to be copied
shell: "cd /var/log; find . -maxdepth 1 -type f | cut -d'/' -f2"
register: files_to_copy
- name: Copy the log files
fetch:
src: /var/log/{{ item }}
dest: ./downloads/{{ inventory_hostname }}/
with_items: "{{ files_to_copy.stdout_lines }}"