Logging
Ansible Logging
By default, Ansible doesn’t log anything, information is written to STDOUT
log_path=: set defaults section of ansible.cfg to force writing log files
or set $ANSIBLE_LOG_PATH environmental variable
Make sure to configure logrotate on ansible log files
Configure Callback Settings
While only one callback can handle stdout at a time, you can enable additional callbacks to perform other actions. For example, the following configuration enables the ansible.posix.profile_tasks and ansible.posix.timer callbacks. The profile_tasks callback summarizes task execution time at the end of the play, and the timer callback provides timestamps for each task. Finally, the community.general.yaml stdout callback provides task output in YAML format
[defaults]
stdout_callback=community.general.yaml
callbacks_enabled=ansible.posix.profile_tasks, ansible.posix.timer Logging to separate file for each host
using log_plays community callback plugin
[defaults]
inventory=./csvinv.yaml
ansible_host_checking=False
# Still log in to one common file
log_path=./ansible_log.txt
# Need to install plugin using: ansible-galaxy collection community.general
callbacks_enabled=ansible.posix.profile_tasks,community.general.log_plays
[callback_log_plays]
# logs folder will be created
log_folder=logsReference
https://www.redhat.com/sysadmin/ansible-logs-customize
https://blog.devgenius.io/a-deep-dive-intologging-mechanisms-in-ansible-f78b6466e82c
Last updated