separate logfile per target

22 views
Skip to first unread message

dulh...@mailbox.org

unread,
Jun 30, 2023, 2:54:28 AM6/30/23
to ansible...@googlegroups.com
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
 

Thanh Nguyen Duc

unread,
Jun 30, 2023, 3:19:31 AM6/30/23
to ansible...@googlegroups.com
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...@googlegroups.com> đã viết:
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 received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5802550.421232.1688108053966%40office.mailbox.org.

dulh...@mailbox.org

unread,
Jun 30, 2023, 6:52:57 AM6/30/23
to ansible...@googlegroups.com
hi,
On 06/30/2023 9:19 AM CEST Thanh Nguyen Duc <ng.duct...@gmail.com> wrote:
 
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
 
 
Vào Th 6, 30 thg 6, 2023 vào lúc 14:54 dulhaver via Ansible Project <ansible...@googlegroups.com> đã viết:
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 received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5802550.421232.1688108053966%40office.mailbox.org.

 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnV6343ds0dmXVPiQD8Uqtosuzo2LpRXcy%3DtkVdDZeSc-vEvw%40mail.gmail.com.
 
---

gunnar wagner | fichtestr. 1, 19386 lübz | fon: 0176 7808 9090

Thanh Nguyen Duc

unread,
Jun 30, 2023, 7:20:48 AM6/30/23
to ansible...@googlegroups.com
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

image0.png

On 30 Jun 2023, at 18:52, dulhaver via Ansible Project <ansible...@googlegroups.com> wrote:



dulh...@mailbox.org

unread,
Jun 30, 2023, 11:29:24 AM6/30/23
to ansible...@googlegroups.com
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

Abhijeet Kasurde

unread,
Jun 30, 2023, 12:14:40 PM6/30/23
to ansible...@googlegroups.com
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
```



--
Thanks,
Abhijeet Kasurde

dulh...@mailbox.org

unread,
Jul 2, 2023, 11:05:52 AM7/2/23
to ansible...@googlegroups.com
 
thx, that's what I was looking for. 
On 06/30/2023 6:14 PM CEST Abhijeet Kasurde <akas...@redhat.com> wrote:
 
 
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
```

On Fri, Jun 30, 2023 at 8:29 AM dulhaver via Ansible Project <ansible...@googlegroups.com> wrote:
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


On 30.06.23 13:20, Thanh Nguyen Duc wrote:
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
 
Reply all
Reply to author
Forward
0 new messages