CICD-255 · Rolling server updates
Encyclopedia · Ansible and configuration management · All snippets
Previous · CICD-254 · Next · CICD-256
1. Where it fits
- Placement In the controller's rolling deployment playbook.
- Prerequisites controller with reviewed inventory, pinned Ansible collections and a non-production target.
- Platforms local-lab.
2. Copy the snippet
yaml
- name: Update one web host at a time
hosts: web
serial: 1
any_errors_fatal: true
tasks:
- ansible.builtin.import_role:
name: deploy_web3. How it works
serial restricts each batch to one host, while any_errors_fatal stops further batches on unhandled failures. The deployment role must include its own drain and health checks.
A failed canary host stops the remaining batches.
flowchart TD
N1["Drain and update first host"]
N2{"Health passes"}
N1 --> N2
N3["Rejoin and continue"]
N2 -->|Yes| N3
N4["Stop remaining batches"]
N2 -->|No| N4
classDef trigger fill:#EFF6FF,stroke:#0540F2,color:#0A0A0A
classDef build fill:#CCFBF1,stroke:#0D9488,color:#0A0A0A
classDef test fill:#EEF2FF,stroke:#4F46E5,color:#0A0A0A
classDef gate fill:#FEF3C7,stroke:#D97706,color:#0A0A0A
classDef security fill:#EDE9FE,stroke:#7C3AED,color:#0A0A0A
classDef deploy fill:#D1FAE5,stroke:#059669,color:#0A0A0A
classDef fail fill:#FEE2E2,stroke:#DC2626,color:#0A0A0A
class N1,N3 deploy
class N2 gate
class N4 fail
4. Verify the result
Implement drain, health check and rejoin in deploy_web. A failed first host halts the batch.
Validation syntax-validated (YAML parse). Status definitions.