Use this when workflows repeat steps over items.
Loops · Workflow Automation
Loops in workflows repeat steps over a list of items, such as each server or each user, with options to run them in sequence or parallel and handle per-item failures.
1. Loops repeat steps over lists or until conditions.
2. Limit iterations.
3. Handle per-item errors.
4. Parallelise when safe.
5. Avoid infinite loops.
list → loop → per-item steps
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 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as branch condition drift, hidden dependency, duplicate parallel mutation, approval bypass, retry storm, partial rollback and successful orchestration with failed consumer state, choosing the cases most relevant to iteration input set, ordering, per-item status, break/continue/failure behavior and safe handling of partial progress.
Step 2 Common mistakes Narrow the fault
- One API call per item when the module accepts a list.
- Loops without a stop condition.
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.
- Loops repeat steps per item.
- Choose sequential or parallel.
- Handle per-item failures.
- Loop over items with limits — iteration
- Max iterations — safety
- Per-item error handling — resilience
ReferenceWhy it matters1 section · depth on demand
What it is
Loops repeat a step for each item in a list: hosts, VLANs, users.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Loops repeat a step for each item in a list — every device, user, VM or file. They turn a single-item workflow into a bulk operation, which is efficient and also multiplies the impact of any mistake.
Design points:
| Question | Options |
|---|---|
| Sequential or parallel iterations? | Parallel with a concurrency limit |
| What if one item fails? | Continue and report, or stop |
| How large can the list be? | Pagination, batching |
| Progress tracking | Record per-item status for resume |
# Ansible
- name: Create VLANs
cisco.ios.ios_vlans:
config: [{ vlan_id: "{{ item.id }}", name: "{{ item.name }}" }]
loop: "{{ vlans }}"
loop_control: { label: "{{ item.id }}" }
Always test a loop with a list of one before running it on hundreds of items.
Example
- name: Create VLANs
cisco.ios.ios_vlans:
config: "{{ vlans }}"
state: merged
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 Workflow Automation > Loops. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For iteration input set, ordering, per-item status, break/continue/failure behavior and safe handling of partial progress, prefer typed fields and stable IDs over human presentation text.