2022-06-23 13:26:07 +00:00
|
|
|
---
|
|
|
|
|
- name: Copy the contents of the "/var/log" folder to the Ansible controller
|
2023-08-02 13:15:36 +00:00
|
|
|
hosts: all
|
2022-06-23 13:26:07 +00:00
|
|
|
become: yes
|
|
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
|
|
|
|
|
|
- name: Generate the list of files to be copied
|
2022-06-28 21:47:18 +00:00
|
|
|
ansible.builtin.shell: "cd /var/log; find . -maxdepth 1 -type f | cut -d'/' -f2"
|
2022-06-23 13:26:07 +00:00
|
|
|
register: files_to_copy
|
|
|
|
|
|
|
|
|
|
- name: Copy the log files
|
2022-06-28 21:47:18 +00:00
|
|
|
ansible.builtin.fetch:
|
2022-06-23 13:26:07 +00:00
|
|
|
src: /var/log/{{ item }}
|
|
|
|
|
dest: /home/vlad/Desktop/ansible/dnaclab_linux/logs/
|
|
|
|
|
with_items: "{{ files_to_copy.stdout_lines }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|