Chapter Ten

Orchestration & Scale

How a play moves a whole fleet through its tasks, and how you bound the damage when a change is wrong. Strategies and forks, serial batching and rolling deploys, delegation to the load balancer, async for long jobs, and the throttles that stop a push tool from pushing a mistake everywhere at once — assembled into a zero-downtime rollout of the Larkspur prod web tier.

6 topics

Everything before this chapter shaped a single host well. This chapter is about the fleet — how Ansible moves dozens of hosts through one play, in what order, how many at a time, and what happens when host four of six fails. The running example is Larkspur's Layer B: six prod web hosts behind HAProxy on lb1.larkspur.io, staging and prod, the real thing a deploy has to touch without dropping a request.

This is also where the spine of the course pays off. Ansible keeps no state file and pushes changes from a control node rather than waiting for each host to pull — and an ordered, gated, cross-host rollout is exactly what that push model does cleanly and a pull model cannot. The six topics build toward one marquee play: a rolling deploy that drains each web host from the load balancer, deploys it, health-checks it, and returns it to the pool, one host out of service at a time.

Topics in This Chapter

Topic 57
Execution Strategies
How a fleet moves through a play's tasks — linear's per-task barrier, free's independent race, and the niche host_pinned. Why strategy is ordering discipline and forks is concurrency, and why confusing the two is the usual mistake.
ConceptOrchestration
Topic 58
forks, serial, and Rolling Updates
Two numbers, constantly mixed up: forks is control-node parallelism (default 5), serial is batch size per wave. Lists and percentages, and how serial plus forks become a rolling deploy of the prod web tier.
OrchestrationScale
Topic 59
Delegation
When a task aimed at one host must run somewhere else. delegate_to for the HAProxy drain on lb1, run_once for fleet-singular steps, delegate_to localhost for external calls, and whose facts delegate_facts attaches.
Orchestration
Topic 60
Async Tasks and Polling
A 30-minute reindex outlives the SSH connection unless you detach it. async with poll waits in the background; poll 0 fires and forgets; async_status reaps the result. How long jobs survive on a push tool.
Workflow
Topic 61
Batching and Throttling
The guardrails that stop a fleet-wide mistake. serial for wave size, max_fail_percentage for the abort threshold, throttle for one hot task, and --limit for the operator override — each catches a different failure.
ScaleSafety
Topic 62
Multi-tier Orchestration
The chapter's worked example: a zero-downtime rolling deploy of the 6-host prod web tier behind HAProxy. Drain, deploy, health-check, re-add — one host at a time, guaranteed re-add on failure, db before web.
OrchestrationDeploy