← Ansible: automate changes and recover services
04 / 6 · 40 MIN

Batch orchestration

Control concurrency, shared dependencies, and stopping criteria.

Concept and mechanism

A distributed change needs to limit removed capacity and observe results before continuing. serial defines how many hosts complete the play in each batch. forks limits concurrent workers, while throttle can reduce concurrency for a task or block; it cannot raise a lower existing limit. Do not confuse these options with health validation: a small batch can still fail on every member. Under the ordinary linear strategy, each task progresses across the batch before the next task. A different strategy may change coordination between hosts, so examples and assumptions should identify the mode used.

Guided application

In an original exercise, eleven servers use serial=4: batches contain four, four, and three hosts. A run_once task executes once per batch in this model, potentially repeating a migration intended to be global three times. Plan that action as an explicitly single step. Delegating tasks from several hosts to one server does not remove concurrency: several workers may write the same file. Use appropriate serialization or an aggregated operation. Also define stopping criteria. With five hosts in a batch and max_fail_percentage=20, one failure equals the threshold and two exceed it. That behavior should match approved risk tolerance.

IN PRACTICE

Eleven hosts, serial=4: three batches; run_once does not automatically mean one global execution.

Common pitfalls

Forks as batches; delegate_to as a mutex; equal threshold as exceeded; serial as a health check.

Related topics: Inventory and execution context · Tasks and desired state · Validation and handlers

Take this idea with you

Connect batch size, concurrency, capacity, and continuation decisions.

Create account

Reference: Controlling playbook execution: strategies and more · Ansible community 14 / ansible-core 2.21 documentation consulted 2026-09-30; executor, collection and plugin compatibility requires confirmation