Pcornel
Automation · Idempotency

State Comparison

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

Back to the Topic

Answer

State comparison reads the current value, compares it with the desired value and decides whether to act, which is the core of every idempotent step and of diff or check-mode output.

Remember

  • Read the current value first.
  • Compare it with the desired value.
  • Act only when they differ.

First checks

  • Read current state before change — facts
  • Normalised comparison (ordering, defaults) — accurate diff
  • Diff output — visibility

Verify in this order

current + desired → normalised diff → actions

Where it usually breaks

Configuration/input → graph/state refresh → plan → provider API request → provider terminal result → resource read-back → effective service state → workload.

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

Confirmation

Confirm action

Continue?