Search code examples
ansibleansible-2.xansible-inventoryansible-template

How to specify log per task on ansible playbook


I have 1 roles with 14 tasks, when running roles, they will run 14 tasks in turn, and the results return all 14 tasks, is there any other way for me to have each task have a separate log file in ansible? ? If possible please show me the example, thanks


Solution

  • The thing you want is a stdout callback, of which log_plays most closely matches your description. However, it is per-host, not per task, so you'll need to copy the code into your playbook as described by developing your own plugin and then modify it in order to get the behavior you expect.