Ansible can report execution time for each task. And total time taken for playbook execution. It is more useful to estimate the time of completion as specially for long running jobs.
For ansible > 2.0, the plugin named callback comes as built-in. To enable add the shown directive to ansible.cfg. I have used and it is working as expected.
#/etc/ansible/ansible.cg callback_whitelist = profile_tasks
Sample outputs
At end of each task, these values reported in shown format.
<Task start time stamp> (<time elapsed by previous task>) (<current elapsed execution time for playbook>)
At end of playbook run nice formatted task list with execution time been reported.
OS upgrade task --------------------------------1806.61s reboot server task--------------------------------80.03s Collect package details task-----------------------3.62s setup----------------------------------------------3.60
The whole output upon execution of simple playbook.
PLAY *************************************************************************** TASK [setup] ******************************************************************* Wednesday 10 January 2018 11:29:10 +0530 (0:00:00.093) 0:00:00.093 ***** ok: [test03] ok: [test04] TASK [create user on remote machine] ******************************************* Wednesday 10 January 2018 11:29:16 +0530 (0:00:06.002) 0:00:06.096 ***** ok: [test03] ok: [test04] TASK [copy ssh public key to remote host] ************************************** Wednesday 10 January 2018 11:29:16 +0530 (0:00:00.217) 0:00:06.313 ***** ok: [test03] ok: [test04] TASK [Test the user access] **************************************************** Wednesday 10 January 2018 11:29:16 +0530 (0:00:00.291) 0:00:06.605 ***** changed: [test03 -> localhost] changed: [test04 -> localhost] PLAY RECAP ********************************************************************* test03 : ok=4 changed=1 unreachable=0 failed=0 test04 : ok=4 changed=1 unreachable=0 failed=0 Wednesday 10 January 2018 11:29:17 +0530 (0:00:00.765) 0:00:07.370 ***** =============================================================================== TASK: setup ------------------------------------------------------------- 6.00s TASK: Test the user access ---------------------------------------------- 0.77s TASK: copy ssh public key to remote host -------------------------------- 0.29s TASK: create user on remote machine ------------------------------------- 0.22s
For ansible < 2.0 refer the github article.
Hope it helps you. If you have any comments, please post below.
Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website
How to save in the execution time details in text output file
Can you try with shell output redirection method?