Use this when systems slowly diverge from their intended configuration.
Configuration Drift
Configuration drift is the gradual divergence of systems from their intended configuration through manual fixes, ad hoc changes and partial runs, leading to inconsistent and fragile environments.
1. Configuration drift: differences from the declared configuration.
2. Caused by manual changes, emergency fixes, other tools, updates.
3. Detect regularly.
4. Codify legitimate changes.
5. Revert others.
declared config → compared with actual → difference = drift
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
git diff --exit-code <baseline-ref> -- <managed-path>Primary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Command read-back and what it shows Verify boundary
Verification for Drift Management → Configuration Drift must distinguish state, not merely report that a command ran. With git diff --exit-code <baseline-ref> -- <managed-path>, known-good means the current observation and approved desired revision refer to the same target and scope, material differences are either eliminated or explicitly approved, and a fresh recollection produces the expected classification; known-broken/suspicious means unexplained material differences persist, the same drift reappears after reconciliation, or a clean diff depends on stale/partial observation data. The diff shows only the textual delta between the chosen desired and observed artifacts, but it does not show freshness, authorization of the change or workload impact.
Step 2 Verification path Verify boundary
Record desired revision, target object ID, detector/run ID and drift record; inspect the runtime/control-plane result; then query the actual managed object state and the recorded drift/remediation decision through an independent read path and compare it with the versioned intent. For Drift Management → Configuration Drift, the evidence must connect the control-plane result to the actual managed object state and the recorded drift/remediation decision and explain any gap between desired, controller-reported and consumer-visible state.
Step 3 Common mistakes Narrow the fault
- Ignoring small drift until it piles up.
Step 4 Observation-driven branch and next-check logic Narrow the fault
When Drift Management → Configuration Drift fails, reproduce the smallest original case and capture git diff --exit-code <baseline-ref> -- <managed-path> before mutation. Use the observation to choose the next check: if the diff is against an old or wrong desired revision, fix baseline selection; if the observed snapshot is stale/incomplete, recollect before remediation; if both inputs are trustworthy and material drift remains, identify the responsible change path and choose reconcile, approve or deliberately defer.
Step 5 Where it fails Narrow the fault
Failure analysis for Drift Management → Configuration Drift should follow the path through the components: desired revision → actual-state read → normalize/compare → drift classification → approval/remediation → target → re-read. Common failure classes include stale actual state, noisy computed fields, wrong identity match, over-broad ignore rules, concurrent changes and remediation creating new drift. Before retrying a mutating operation, read current target state using the stable identity desired revision, target object ID, detector/run ID and drift record; if state is unknown, stop broad retries.
- Manual fixes and partial runs cause drift.
- Drift makes environments fragile.
- Detect and correct regularly.
- Drift examples (manual edits, hotfixes, other tools) — causes
ansible-playbook site.yml --check --diff— detect- Change audit logs — who
ReferenceWhy it matters1 section · depth on demand
Method
Configuration drift is any difference between a system's running configuration and its approved desired configuration. Handling it follows a consistent method.
1. Detect drift on a schedule (dry run, diff against rendered config).
2. Identify who/what changed it (audit logs, AAA accounting, change records).
3. Classify: approved emergency change, accidental change, or unauthorised change.
4. Resolve: write approved changes back to the desired state, or revert others.
5. Escalate unauthorised changes as security events.
diff <(ssh sw01 'show running-config' | sed '1,/^!$/d') rendered/sw01.cfg
Ignore volatile lines (timestamps, counters) in comparisons so real drift is not buried in noise.
ReferenceHow it works1 section · depth on demand
How it works
Drift Management → Configuration Drift should be reasoned about as a state pipeline, not as one command outcome. The responsible state is desired-state revision, observed-state snapshot, normalization rules and the delta classifier that decides whether a difference is material drift. Drift detection compares a time-bounded observation with an approved desired state after removing intentionally volatile fields; ownership of the observation and ownership of the desired source must remain distinct so stale data is not mistaken for convergence; meanwhile collection freshness, target identity, secret redaction, generated values and exception windows are separate things to check. This distinction is especially important because a difference is not automatically harmful drift and no difference is not evidence of correctness when the observation is stale, partial or taken from the wrong target.
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
Drift Management → Configuration Drift is owned at runtime by the desired-state source and drift detector/reconciler comparing it with current target state. Its durable intent is versioned desired state, comparison scope, ignore rules and remediation/approval policy; the stable identity contract is desired revision, target object ID, detector/run ID and drift record. The consumer-visible target is the actual managed object state and the recorded drift/remediation decision. The operating invariants are that desired and actual sources are explicit, comparison is normalized, ignored fields are reviewed, drift records carry object identity and remediation is not triggered from stale reads. Follow the chain of components desired revision → actual-state read → normalize/compare → drift classification → approval/remediation → target → re-read and record which layer currently owns truth. The linked authority for bounded mechanics is HashiCorp Developer — Manage resource drift; documentation support is separate from observed lab/production Evidence.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Drift Management > Configuration Drift. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://developer.hashicorp.com/terraform/tutorials/state/resource-drift · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
Capture at minimum desired revision, object ID, actual version/timestamp, diff, ignored fields, drift class, remediation/run ID and post-state diff.