Interview Prep/Ansible/Performance and Scale

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.

All Ansible questions Roadmap: Ansible

More on Performance and Scale