Skip to main content

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​

  1. Check current state before acting.
  2. Apply changes only if needed.
  3. Make every step safe to repeat.
  4. 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.