State Reference

on this page

This page describes the persisted runner state written by internal/runner/state.go.

Default Locations

Preflight writes state files to:

  • state/provision.json for local applies
  • state/targets/<host>.json for inventory-backed applies

Inspection commands such as preflight state show, preflight state diff, and preflight apply --bundle can read or write a different state file with --state-file.

File Shape

Current state files use the v2 snapshot model:

FieldTypeMeaning
versionintegerState file format version
last_appliedtimestampTime of the most recent successful apply write
tasksobjectStable task-key to task snapshot map

Legacy results-only files are still readable and are promoted in memory to the current snapshot form.

Task Snapshot Fields

Each task snapshot records:

FieldTypeMeaning
task_keystringStable task identity derived from task lineage
task_namestringRendered task name
modulestringModule name
depends_onstring[]Stable keys for dependencies
task_hashstringHash of task identity plus params
param_hashstringHash of rendered params plus task execution options such as become
param_summaryobjectRedacted summary of rendered params and execution options used for comparisons
statusstringRecorded execution status
messagestringRecorded task message
timestamptimestampTask result timestamp

Redaction

State files do not persist decrypted secret values.

param_summary is redacted for secret-bearing fields such as:

  • passwords
  • tokens
  • private keys
  • become passwords
  • any secret:<name> reference values

Diff Statuses

preflight state diff uses these statuses:

StatusMeaning
NEWThe task is present in the current plan but not in recorded state
CHANGEDThe task exists in both places but its structural hash changed
UNCHANGEDThe task matches recorded state
REMOVEDThe task exists in recorded state but not in the current plan
STATUS-ONLYThe task shape matches, but the recorded status still matters operationally

Host Context Matters

State comparison uses the selected host context to render task names and params before hashing them. For inventory-backed diffs, pass the relevant --target value so vars.*, target.*, facts.*, and env.* expressions are evaluated for the correct machine.

Why Stable Task Keys Matter

Task keys are based on lineage, not just list position. That improves comparisons when:

  • a task is inserted earlier in a playbook
  • an action expands into several child tasks
  • nearby refactors happen without actually changing a task’s identity
CommandPurpose
preflight state showShow a state file through the selected output renderer
preflight state diff <playbook>Compare a plan to a selected state file