serial & Rolling Batch Execution
Roll changes out in safe waves.
serial & Rolling Batch Execution is a free Ansible Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
All at Once Is Risky
Updating every server in one sweep is fast, but a bad change can take down your whole fleet at the same instant. Rolling updates avoid that.
Meet serial
The serial keyword tells a play to work through hosts in batches instead of all together. You update a slice, then move to the next.
- hosts: web
serial: 2A Number Sets Batch Size
Give serial a number and each batch holds that many hosts. With serial 2, Ansible finishes the whole play on two hosts before touching the rest.
Use a Percentage
A percentage scales with fleet size. serial: 25% updates a quarter of hosts per wave, whether you have 8 servers or 800.
serial: 25%Ramp Up with a List
Pass a list to grow batches as confidence builds: start with one host, then more. This is the classic canary then full rollout pattern.
serial:
- 1
- 5
- 25%Whole Play, Per Batch
Crucially, serial runs the entire play on a batch before the next. The first slice is fully done while later hosts have not started.
Fail Fast with max_fail_percentage
Pair serial with max_fail_percentage to abort the rollout if too many hosts in a batch fail, stopping a bad change before it spreads.
- hosts: web
serial: 25%
max_fail_percentage: 30Drain Before You Touch
A safe wave first removes each batch from the load balancer, applies changes, then adds the hosts back so users never hit a server mid-update.
Keep the Service Up
Because other batches keep serving traffic, rolling updates give you zero downtime: the app stays available throughout the deploy.
serial Meets forks
Within a batch, forks still control parallelism. serial caps how many hosts a wave touches; forks caps how many run at once inside it.
Test on One First
Starting with serial: 1 makes the first host a canary. If it breaks, the run stops there and the rest of your fleet stays healthy.
Quick Check
You want to update 100 web servers a few at a time without an outage.
Recap
Use serial to roll changes out in batches, ramp with a list, and add max_fail_percentage to bail early. That is zero-downtime deploys. 🌊
Frequently asked questions
Is the “serial & Rolling Batch Execution” lesson free?
Yes — the full text of “serial & Rolling Batch Execution” is free to read here on the web, and the Ansible Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO.
What will I learn in “serial & Rolling Batch Execution”?
Roll changes out in safe waves. You practise Ansible Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Ansible Academy?
No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “serial & Rolling Batch Execution” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Ansible Academy lesson?
Yes. Every Ansible Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- forks & Parallelism Tuning
- Strategies: linear, free & host_pinned
- SSH Pipelining & Connection Reuse
- serial & Rolling Batch Execution