Example — Pattern Content Type
Example title: Idempotent Deploy Pattern
Guidance: Use pattern for a reusable approach to a recurring problem. Explain the problem, the structure, and the rationale — but keep the prose lean and show the working steps.
Example content
An idempotent deploy pattern for safely re-running a deployment without breaking an already-deployed system. The goal is that every step checks state first, applies changes only when needed, and finishes with verification.
Problem
Re-running a deploy should not break an already-deployed system. Partial failures and retries must leave the service in a known state.
Structure
- Check current state before acting.
- Apply changes only if needed.
- Make every step safe to repeat.
- Verify the final state.
Example flow
# 1. Check
if systemctl is-active --quiet myapp; then
echo "already running"
fi
# 2. Apply only if needed
[ -f /opt/myapp/new ] || cp /opt/myapp/new /opt/myapp/current
# 3. Restart safely
systemctl restart myapp
# 4. Verify
systemctl is-active myapp
Rationale
- Reduces risk during retries and partial failures.
- Makes automation trustworthy.
- Keeps rollback simple.