AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

How to Do Rolling Updates with Zero Downtime in Ansible

By Luca Berton · Published 2024-01-01 · Category: web-servers

How to perform rolling updates in Ansible with serial, load balancer integration, health checks, and rollback. Zero-downtime deployment patterns with examples.

How to Do Rolling Updates with Zero Downtime in Ansible

Rolling updates deploy to a subset of servers at a time, keeping your service available throughout. Ansible's serial directive makes this straightforward.

Basic Rolling Update

Serial Options

With Load Balancer Integration

Fail Fast: max_fail_percentage

Canary Deployment Pattern

FAQ

How does serial work in Ansible?

serial limits how many hosts are processed at a time. With serial: 2 and 10 hosts, Ansible deploys to 2 hosts, waits for completion, then moves to the next 2. This prevents all hosts from being down simultaneously.

What is max_fail_percentage?

max_fail_percentage stops the play if too many hosts fail. Set to 20 to abort if more than 20% of hosts in a batch fail, preventing a bad deployment from rolling out to all servers.

How do I do a canary deployment with Ansible?

Use a ramping serial: [1, 5, "25%"] or split into two plays — first targeting one host (the canary), then the rest after validation. Add a pause for manual approval between stages.

Related ArticlesAnsible run_once: Execute Tasks OnceAnsible Playbook GuideAnsible Handlers: Run Tasks on Change

Category: web-servers

Browse all Ansible tutorials · AnsiblePilot Home