From eefc8f99e237fd41795c85b67afb4ec2c563b575 Mon Sep 17 00:00:00 2001 From: Vlad Raducanu Date: Tue, 6 Apr 2021 12:58:06 +0100 Subject: [PATCH] Added a new playbook which copies logs files to local machine. Works on Linux machines which use /var/log/ as the log file location --- home_linux/get_all_logs.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 home_linux/get_all_logs.yml diff --git a/home_linux/get_all_logs.yml b/home_linux/get_all_logs.yml new file mode 100644 index 0000000..55b5dd2 --- /dev/null +++ b/home_linux/get_all_logs.yml @@ -0,0 +1,21 @@ +--- +- name: Copy the contents of the "/var/log" folder to the Ansible controller + hosts: all + roles: + - common + become: yes + + 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: /mnt/c/Ansible/fetched_logs + with_items: "{{ files_to_copy.stdout_lines }}" + + +