By default, the default Ansible configuration file (/etc/ansible/ansible.cfg) has log_path commented out, like this.
#log_path = /var/log/ansible.log
When commented out, Ansible will log events to the machines syslog (system log daemon). As an example, syslog may write Ansible events to the /var/log/messages file.
Mar 22 12:55:08 [localhost] ansible-command: Invoked with creates=None executable=None _uses_shell=True strip_empty_ends=True _raw_params=ping -c4 was2.software.eng.us removes=None argv=None warn=True chdir=None stdin_add_newline=True stdin=None
There are a number of ways to configure Ansible to log events to a custom log file, where the higher option in this list will take precedence over the lower options.
Here is how you could set a temporary log path using the ANSIBLE_LOG_PATH variable. Or, you can include this in your users hidden .bash_profile file (e.g. /home/john.doe/.bash_profile) to make this setting permanent.
Define the log_path directive in your Ansible configuration file (ansible.cfg), where the higher option in this list will take precedence over the lower options.
In this example, Ansible will start to log events to /var/log/ansible.log.
log_path = /var/log/ansible.log
If you are using your own ansible.cfg file (e.g. /home/john.doe/ansible.cfg) instead of the global /etc/ansible/ansible.cfg file, the log_path directive must be under the [defaults] header.
Create and rotate the log file
You may need to create the log file and update the permission so that it has the write permission for user, group and other. You may want to also configure logrotate to rotate the log files.
touch /var/log/ansible.log chmod 0666 /var/log/ansible.log