How do you cut down the number of tasks without hurting readability?
IntermediateProductionPerformance and Scale
Answer
Prefer one template over a dozen lineinfile edits, pass lists to modules that accept them, use copy or synchronize on a directory instead of looping over files, and drop tasks that only gather information you can get from facts.
Combine several shell commands into a script only when each step is inherently non-idempotent anyway. Do not merge unrelated actions into mega-tasks to save seconds: you lose clear change reporting. The goal is the minimum number of round trips for the same state, not the minimum number of lines.
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 find out which tasks are slow?BeginnerHow do you reduce the cost of fact gathering?Intermediate