Vol. I§Zero-downtime series§A series for junior developers
Zero-downtime delivery·6 / 10·
The playbook only touches the idle slot
Ansible reads state.json, picks the empty slot, and renders compose there. Including three production scars: a port it does not own, a silent compose down, and the first deploy.
This is the longest chapter of the series — rightly so, because the playbook is where every previous chapter meets. It never stops the live slot. It reads state.json, picks the opposite of live, and renders compose for that slot only.
Six taught steps
Read state. The first deploy pretends the other slot is live so the first step stays deterministic.
Check the target port. If another process holds it, stop.
Pull the image and start the idle slot.
Run the health check.
Patch the Caddy route.
Stop the old slot and write the new state.
Slot playground · idle-deploy
Blue is serving. Green is empty.
Blue is serving. Green is empty.
The playbook pulls the image onto the idle slot. Blue still answers.