dulhaver
(Gunnar)
June 30, 2023, 6:54am
1
we where wondering whether there is a method to generate logfiles per remote target on playbook executions?
In other words … one runs a playbook on 50 targets and gets 50 logfiles (1 per target) out of it.
I guess another way to separate things a litte in the logs would be to use serial: 1
You may create a log file with hostname, in my case i will create a log file with name: {{inventory_hostname}}_log.xx then pull them back.
Vào Th 6, 30 thg 6, 2023 vào lúc 14:54 dulhaver via Ansible Project <ansible-project@googlegroups.com > đã viết:
dulhaver
(Gunnar)
June 30, 2023, 10:52am
3
hi,
You may create a log file with hostname, in my case i will create a log file with name: {{inventory_hostname}}_log.xx then pull them back.
that’s what I want. Good to hear that you are doing that. Can you share how that practically is being achieved?
putting …
log_path = {{ inventory_hostname }}_ansible.log
… in the ansible.cfg does not work
You want log for client or ansible system log? In my case i use j2 template to create a log with csv format to monitor certain tasks to check the timing of the main tasks if be executed and how long it took. Not sure this is what you want? If you want the log which record all stdout of everything for each playbook per each managed host then you may try the below
dulhaver
(Gunnar)
June 30, 2023, 3:29pm
5
Maybe I am not explaining myself good enough
I run a playbook against 30 targets
By default I get the complete log (TASKS by TASK) inside an ansible.log file (so all targets mixed into one big logfile)
I want to receive 30 (1 logfile per target) logfiles instead
(attachments)
Akasurde
(Abhijeet Kasurde)
June 30, 2023, 4:14pm
6
Please check the tree callback plugins - https://docs.ansible.com/ansible/latest/collections/ansible/builtin/tree_callback.html
This callback plugin logs on per-host basis.
[defaults]
stdout_callback=tree
inventory=hosts
[callback_tree]
directory=<LOG_DIRECTORY>/tree
will generate -
# ls -l tree
total 16
-rw-r--r-- 1 akasurde staff 40 30 Jun 09:10 192.168.64.3
-rw-r--r-- 1 akasurde staff 40 30 Jun 09:10 localhost
(attachments)
dulhaver
(Gunnar)
July 2, 2023, 3:05pm
7
thx, that’s what I was looking for.