In this recipe, we will outline how to get the time that various tasks within an Ansible playbook take to execute. This can help us understand which specific task or role is taking the largest portion of time during a playbook run, and can help us to optimize our playbooks.
- Update the ansible.cfg file to include the following line:
< --- Output Omitted for brevity ---->
callback_whitelist=timer, profile_tasks, profile_roles
- List all the tasks in the ansible-playbook code for reference:
$ ansible-playbook pb_generate_config.yml --list-tasks
- Run the Ansible playbook:
$ ansible-playbook pb_generate_config.yml