How do you find out which tasks are slow?
BeginnerProductionPerformance and Scale
Answer
Enable the timing callbacks.
ANSIBLE_CALLBACKS_ENABLED=ansible.posix.profile_tasks,ansible.posix.timer \
ansible-playbook site.yml
At the end, profile_tasks prints the slowest tasks, and per-task timestamps appear as you go. For per-role breakdowns, ansible.posix.profile_roles does the same by role. Fix the top three offenders, run again, and repeat. Guessing without data usually optimises the wrong thing.
More on Performance and Scale
Why can Ansible be slower than a shell script for 100 servers, and what dominates the time?BeginnerHow do you choose the `forks` value?BeginnerWhat is SSH pipelining and why does it help?BeginnerWhich SSH settings matter for performance and stability?IntermediateHow do you reduce the cost of fact gathering?IntermediateWhat is Mitogen for Ansible and would you use it?Advanced