Use this when checks must pass before any change starts.
Preconditions · Automation Design
Preconditions are checks before an automation changes anything, such as the target being reachable, enough disk space, the right version, or a maintenance window being open.
1. Preconditions must be true before acting.
2. Check connectivity, versions, health, approvals, windows.
3. Abort safely if not met.
4. Log results.
5. Fail fast.
preconditions checked → proceed or abort
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
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 Common mistakes Narrow the fault
- Checking preconditions only on the first host.
- Skipping checks in emergency runs.
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.
- Preconditions are checked before anything changes.
- Typical checks: target reachable, disk space, version, window open.
- Failing early avoids half-done changes.
- Precondition checks (reachability, versions, maintenance window) — guards
- Abort on failed precondition — safety
- Logged checks — evidence
ReferenceWhy it matters1 section · depth on demand
What it is
Preconditions are checks that must pass before the automation changes anything: target reachable, correct version, enough capacity, maintenance window, required approvals. Failing early prevents half-applied changes.
ReferenceImportant terms & boundaries2 sections · depth on demand
Example
- name: Check free space before upgrade
ansible.builtin.assert:
that: ansible_mounts | selectattr('mount','equalto','/') | map(attribute='size_available') | first > 2000000000
In depth
Preconditions are the checks an automation makes before it changes anything: is the target reachable, in the expected state, running a supported version, inside a maintenance window, with enough free space? If a precondition fails, the run stops before doing harm. Checking first is cheaper than rolling back afterwards.
Typical preconditions:
| Check | Example |
|---|---|
| Reachability | SSH/API responds |
| Version | Software version in supported list |
| State | No pending reboot, cluster healthy, no active alarms |
| Capacity | Disk, memory, licence available |
| Window | Inside approved change window |
| Input | Variables complete and valid |
- name: Preconditions
ansible.builtin.assert:
that:
- ansible_net_version is version('17.9', '>=')
- free_flash_mb | int > 1200
fail_msg: "Precondition failed on {{ inventory_hostname }}"
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 Automation Design > Preconditions. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/azure/well-architected/operational-excellence/enable-automation · confidence 94%