Interview Prep/Ansible/Performance, Testing and CI/CD

A playbook that touches 200 hosts takes 40 minutes. Where do you start tuning?

IntermediateScenarioPerformance, Testing and CI/CD
Answer

Situation read → Unknown bottleneck; measure first.

What I'd do →

  1. Enable timing callbacks: callbacks_enabled = profile_tasks, timer in ansible.cfg.
  2. Raise forks (for example 50), enable pipelining, and SSH ControlPersist.
  3. Turn off or reduce fact gathering and add fact caching.
  4. Replace loops of package installs with one name: [list] call.
  5. Use async for long independent tasks and strategy: free where safe.
[defaults]
forks = 50
gathering = smart
callbacks_enabled = profile_tasks, timer
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s

Why → Most time is connection overhead and slow tasks; profiling points at the few that matter.

Interview tip → Say "measure, then tune" and name profile_tasks.

All Ansible questions Roadmap: Ansible

More on Performance, Testing and CI/CD