I always like to have logs to refer back to when it comes to most things I do. I have been trying to find ways to do this within Ansible and just could not find the solution that I wanted. I did some more research IE GOOGLE and finally found a very easy solution that I would like to share. Its nothing ground breaking and most will say, I knew that, but for me it fits the bill and does what I want it to do.
Enough of that, lets get into it.
For this example I am going to run a simple win_ping command and output it to a .LOG file in /etc/ansible/logs with date and time of the run.
ansible winservers -m win_ping > "/etc/ansible/logs/ping.$(date +%Y-%m-%d_%H:%M).log"
Doing a simple ll command to list the files you will see in /etc/ansible/logs and see my log file
Again, not complex, maybe not the most elegant but it gets the job done and I can go back and view the results. I wont use this on everything but could be very useful if you are running a command to check for updates and have multiple servers.