Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Drift Detection · Configuration Management

Direct answer

Drift detection in configuration management runs the tool in check mode or compares facts with the desired state on a schedule, reporting resources that would change.

When to use this

Use this when finding systems that would change on next run.

First 30 seconds

1. Detect drift with scheduled check-mode runs or agents.

2. Report per host and resource.

3. Alert on security-relevant drift.

4. Trend over time.

5. Investigate repeat drift.

Operational verification

schedule → check run → drift report → alert

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Ansible latest/current
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformAnsible latest/current · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when finding systems that would change on next run.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

3 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

Verify the detector itself with controlled experiments. First run against a known-converged target and record the expected no-change result for modules that support simulation. Then introduce a bounded, reversible change to a managed property and confirm --check --diff reports the intended difference without applying it. Identify any skipped/unsupported tasks and show their state through independent read-only commands or APIs. After correcting or adopting the drift, re-run the same detector and confirm the managed difference is gone. Also perform a service-facing read-back because configuration equality is not the same as application health. Keep playbook revision, inventory target, effective variables, module/collection version and diff summary with the result so a later run is comparable.

Step 2 Common mistakes Narrow the fault
  • Detection that runs but never alerts.
Step 3 Where it fails Narrow the fault

The first boundary is detector capability: not every task/module can predict changes. The second is input resolution—inventory, variables, templates and facts determine desired values. The third is the resource read/compare implementation, followed by target permissions/connectivity. Finally, a reported difference may be authorized out-of-band change or another controller's ownership rather than a defect. Do not auto-remediate until those boundaries are classified. A task that is skipped in check mode needs another read path; a noisy diff may require better normalization, not an ignore-everything rule. Preserve the original diff and effective desired inputs before changing configuration or state. Re-run the same detection path after correction to show the gap is closed without masking unsupported coverage.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Detect drift by running the tool in check mode or comparing facts.
  • Schedule detection regularly.
  • Report results to owners.
Key checks
  • ansible-playbook site.yml --check --diff — scheduled drift scan
  • Drift report in CI/AWX schedule — automation
  • Alert on drift — notification
ReferenceWhy it matters1 section · depth on demand

In depth

Drift detection compares desired and actual configuration on a schedule and reports differences without (necessarily) changing anything. It is the safe first step before automatic remediation.

ansible-playbook site.yml --check --diff          # differences without applying
terraform plan -detailed-exitcode                 # exit 2 = drift/changes
ApproachNote
Dry-run of normal automationReuses existing code
Config diff vs golden fileSimple for network configs
Policy checks (Batfish, OPA)Rules rather than full config

Send drift reports where someone will act on them, and track the drift count over time.

ReferenceImportant terms & boundaries1 section · depth on demand

Mechanics

Configuration-management drift detection compares managed current state with the state implied by the automation definition. In Ansible, check mode asks supporting modules to predict changes without applying them, while diff mode can show before/after details for modules that implement diff support. That capability is useful but not universal: tasks that do not support check mode may do nothing, and later conditions based on registered results can behave differently because earlier mutations never occurred. Drift detection is therefore only as complete as the resource/module read model. A useful detector scopes comparison to properties the configuration system owns, normalizes expected platform defaults, and distinguishes 'would change' from an operational fault. It should also identify tasks whose simulation semantics are incomplete rather than presenting a false clean result.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
ReferenceConfiguration & state1 section · depth on demand

Lifecycle

Run drift checks from the same reviewed playbook/role revision, inventory and variable set used for enforcement. Pin collections/modules where behavior matters, because provider implementation changes can alter what is considered drift. Keep check-mode exceptions explicit and small; a task forced to run normally during validation should be treated as a mutation boundary, not hidden inside a 'read-only' job. Diff output can contain secrets, so suppress or redact sensitive tasks and store only the evidence required for diagnosis. Schedule drift detection often enough to catch unauthorized/manual changes before the next planned deployment, but avoid auto-applying every difference without classification. Repeated drift should trigger an ownership or process review rather than an endless sequence of automated reversions.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docAnsible latest/current latest/current

Authoritative/upstream documentation reviewed for bounded claims in Configuration Management > Drift Detection. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_checkmode.html · confidence 94%
Embedded reference data

Quick lookup tables

Configuration Management → Drift Detection · operational reference

Context-specific ownership, verification, output and failure-boundary lookup for Configuration Management → Drift Detection.

LayerConfiguration Management → Drift Detection operational reference
Context identityAnsible latest/current + exact revision/input/target identity
Persistent intentVersioned contract/configuration with explicit ownership and prerequisites
VerificationValidate inputs/read current state → exercise bounded operation → independent target read-back
Output contractPreserve structured status/IDs/properties before human formatting
Failure boundarySeparate source/input/engine/controller execution from downstream target outcome
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

Drift output should answer which task/resource would change, which properties differ, and whether the result is a simulation, an unsupported/no-op check, or an actual read failure. Ansible's changed prediction is useful but should be correlated with the diff and module semantics; a clean changed=false from a task that does not implement check mode is not evidence of convergence. Capture before/after snippets only when they are safe, and redact credential-bearing or secret configuration. Summarize unsupported tasks explicitly so the operator knows where coverage is incomplete. For recurring audits, store counts by resource plus stable identifiers rather than huge raw logs, but preserve enough detail to investigate a specific difference. After remediation, a clean drift report plus independent target read-back forms stronger closure evidence than either alone.

Confirmation

Confirm action

Continue?