How to log in a separate file per playbook in Ansible
<p>Instead of the single log file defined in log_path, I want to have separate log files per playbook run in Ansible.</p>

<p>As far as I know there is no built-in way to do that. So I am looking for clever "hacks".</p>

<p>More specifically, I want after a playbook is ran a log file to be generated in the format [playbook name].[date].log</p>

<p>I found <a href="https://stackoverflow.com/questions/29271967/in-ansible-how-can-i-set-log-file-name-dynamilcally">this</a> thread in SO but it doesn't meet my needs. The alias would be a solution if I could pass somehow the playbook name dynamically, not only the date. The lookup solution would be ok if I could copy only the relevant part from the main log file without all the history up until the moment of the copy. Additionally, if you have many playbooks running in parallel I don't know how good this method will work.</p>

<p>Any clues / ideas? What I thought is creating a shell script that would be called inside a playbook to somehow "extract" the relevant entries from the main log and create a separate one. But I believe I am making it too complex.</p>