Safeguard
Developer Tools•

How reliable is Ansible check mode as a preview of changes?

Ansible check mode is a simulation. Modules that do not support it report nothing, and tasks that depend on earlier results may skip. What to rely on.

Safeguard Security Team
3 min read

Ansible check mode is useful but incomplete. It runs without making changes, modules that support it report what they would change, and modules that do not support it report nothing and do nothing. The documentation itself calls it a simulation, so do not treat a clean run as proof.

What check mode does

Run ansible-playbook foo.yml --check and Ansible simulates the play. Diff mode adds before and after comparisons for modules that support it, and the two can be combined for detailed validation.

Known limits

The documentation states two limits that matter for reviewers:

  1. Modules that do not support check mode report nothing and do nothing, so a task can be silent in the preview and still change a host in a real run.
  2. Check mode does not produce output for tasks whose conditionals depend on registered variables, meaning results of earlier tasks. Later tasks may therefore be skipped.

Controlling it per task

A task can set check_mode: true to always run in check mode, or check_mode: false to always make changes, even when the playbook is run with --check. That second setting deserves attention in review.

- name: Always runs for real
  ansible.builtin.command: /opt/tool/refresh
  check_mode: false

A task like this changes the system during what the operator believes is a dry run.

Review table

ObservationWhat it suggests
Many tasks skipped in check modePreview is incomplete, test elsewhere
check_mode: false on a taskIt changes hosts in a dry run, ask why
command or shell tasksOften cannot predict their effect
Output only for supported modulesSilent tasks are unknown, not safe

A safer workflow

  1. Use check and diff mode in CI against a staging inventory.
  2. Flag every check_mode: false in code review.
  3. Prefer modules that support check mode over raw command tasks.
  4. Run a real change on a small canary group first, using --limit.
  5. Keep idempotent tasks so reruns are safe.

Where it fits

Check mode answers the question "what might change on this host?" for supported modules. It does not answer "is this playbook safe to run?". That needs code review, pinned dependencies and limited credentials.

Quick check

Does check mode change anything on hosts?

No, except tasks marked check_mode: false.

Why do some tasks show nothing?

Their modules may not support check mode, or conditionals depend on earlier results.

Is diff mode separate?

They are separate modes that can be used together.

Safeguard offers SBOM and dependency scanning and policy gates that can block a pull request on findings, and you can try a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.