Pcornel
Automation · Ansible

Check Mode

Cheat sheet · https://pcornel.dk/topic.php?topic=5413

Back to the Topic

Answer

Ansible check mode asks supported content to predict changes without applying them, providing planning evidence whose accuracy depends on module/plugin support and observable current state.

Remember

  • Check mode ok ≠ real run guaranteed; external APIs, generated data and unsupported modules can behave differently.
  • changed prediction ≠ actual change applied; check mode normally does not mutate target state.
  • No predicted change ≠ target healthy; the task may validate only a narrow resource boundary.
  • Module supports check mode ≠ every dependent role/task is simulation-safe.

First checks

  • ansible-playbook site.yml --check --diff — dry run
  • check_mode: false for read-only commands — make checks work
  • Modules without check mode support — limitations

Verify in this order

playbook → check mode → predicted changes

Where it usually breaks

Check mode proves what supported content predicts from observable state; it does not prove the real execution will succeed or produce identical results.

Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.

Check Mode Ansible boundary map

BoundaryHealthy evidenceSuspicious evidence
Inputs / selectionCorrect inventory, hosts, variables/facts and content are explicitWrong scope, stale facts, hidden precedence or content-version drift
ExecutionConnection, privilege, module/task context and ordering match intentUnreachable, wrong execution host, privilege/plugin failure or misleading skip/change state
Result semanticsPer-host/item results are preserved and interpreted correctlyAggregate recap hides partial/skipped/handled failures
Target proofResource/workload read-back and rerun confirm convergenceGreen Ansible status treated as end-to-end acceptance

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5413

Confirmation

Confirm action

Continue?