Use it when gating automation around Preconditions. Keep authoritative criteria, immutable source/input, exact target identity, validator version, observed/effective state and workload acceptance as separate proof boundaries.
Preconditions · Validation
Preconditions are explicit facts that must be true at the decision point for an automation step to be valid, safe and deterministic.
1. Preconditions are required states for safe changes.
2. Assert them in code.
3. Abort or skip safely.
4. Document.
5. Test.
preconditions → assert → continue
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
test -r <required-file> && test -n "$<REQUIRED_VAR>"Primary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
operation intent → explicit predicates → authoritative state/version → concurrency guard → guarded mutation → condition/result correlation → postcondition verification
Healthy evidence: predicates are explicit, checked against authoritative current state and coupled to concurrency controls where races can change correctness.
Step 2 Command read-back and what it shows Verify boundary
test -r <required-file> && test -n "$<REQUIRED_VAR>" is the bounded verification surface selected for Validation → Preconditions. A known-good result is all documented preconditions evaluate true for the exact target at a sufficiently fresh timestamp, recovery/rollback material is available and the action begins without bypassing a failed gate. Treat wrong/stale target state, failed dependency/quota/approval, missing recovery prerequisite or automation that proceeds despite a false/unknown precondition as broken/suspicious. The precondition test shows only the conditions it explicitly evaluates at that time; it does not eliminate races or show the subsequent change will succeed.
Step 3 Common mistakes Verify boundary
- Preconditions skipped in emergencies.
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: assumptions are implicit, state is stale, or a check-then-act race permits mutation after the validated condition is no longer true.
Step 5 Observation-driven branch and next-check logic Narrow the fault
For a failing Validation → Preconditions case, freeze scope first: target/object, desired revision or request, and failure time. Inspect test -r <required-file> && test -n "$<REQUIRED_VAR>". Branch on evidence rather than labels: if target identity/version mismatch, refresh inventory/state; if dependency/capacity/approval check fails, resolve the owner before change; if all preconditions pass, re-check the narrow race-sensitive state immediately before mutation when required.
Step 6 Where it fails Narrow the fault
Where Preconditions usually goes wrong: evaluation context, truthiness/type rules, short-circuiting, missing data and deterministic branching.
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.
- Precondition true once ≠ true at mutation time.
- Object exists ≠ object is the intended version or state.
- Lock checked free ≠ lock acquired.
- Dependency healthy ≠ dependency state cannot change during the step.
- Precondition assertions in code (assert/that) — guards
- Required state documented — contract
- Skip/abort behaviour — safety
ReferenceWhat it is1 section · depth on demand
Core model
Define each precondition as an observable predicate, query it from an authoritative source immediately before the guarded action, bind the result to object identity/version, and use atomic or conditional operations where a time-of-check/time-of-use race matters.
ReferenceHow it works1 section · depth on demand
How it works
In Validation → Preconditions, effective state is split across must-be-true state before an automation action, including target identity, current version/state, dependency availability, maintenance/approval context and required recovery material. Preconditions convert hidden assumptions into executable gates so an action stops before mutation when the target or environment no longer matches the state against which the plan was prepared. Concurrent changes, clock/freshness, privileges, capacity/quota and external approvals are separate things to check. This matters because a precondition test passing once can become stale before action, while a failed precondition is a reason to stop/re-plan rather than force the intended operation.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
Preconditions show eligibility only at the observed decision boundary; they do not show postconditions or eliminate races unless execution is guarded atomically.
In depth
Preconditions are the conditions that must be true for an automation step to be valid — for example a VLAN must exist before assigning it, or a host must be in maintenance mode before patching. Encoding them explicitly prevents steps running out of order.
- ansible.builtin.assert:
that:
- "'maintenance' in host_status.tags"
- ansible_facts.mounts | selectattr('mount','equalto','/') | map(attribute='size_available') | first > 2*1024**3
fail_msg: "Host not in maintenance or <2 GB free on /"
Preconditions differ from preflight checks mainly in scope: they guard individual steps, not just the job start.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Validation > Preconditions. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://json-schema.org/learn/getting-started-step-by-step · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Preconditions validation proof-boundary map
Fast criteria/scope, execution and effective-outcome proof boundaries for Preconditions.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Criteria / input | Criteria, source revision, validator and exact target identity are explicit | A generic pass exists without versioned criteria or target correlation |
| Preconditions / operation | Current authoritative facts are bound to the exact operation | Stale preflight or requested state substitutes for execution-time facts |
| Effective outcome | Authoritative state/read-back and service-relevant evidence match the expected result | Tool/test/validator success substitutes for effective target or workload proof |
| Limits / next action | Coverage limits, unknowns and failures drive the next narrower check | Unknown evidence becomes pass, retries hide failures or broad success is inferred from one check |
Deep reference
Healthy vs suspicious evidence
Output interpretation
For Preconditions, rely on structured fields and stable IDs (evaluation context, truthiness/type rules, short-circuiting, missing data and deterministic branching) rather than text formatted for display.