loop
A task keyword that runs the same task once for each item in a list, with the current item available as item.
In more detail
It keeps the action in one place while the data supplies the values that change. Each iteration is reported separately, so one failing item is easy to find. For lists of mappings, read named fields, such as item.name, rather than relying on positions.
Example
loop: "{{ colors }}"Related terms
- item — The variable that holds the current value in each iteration of an Ansible loop.
- YAML list — An ordered series of values, written in YAML as lines that each start with a dash and a space.
- mapping — A collection of named values, each written key: value, where every key appears once.
Taught in
- Conditionals — Ansible Configuration Management at Scale
- Loops — Ansible Configuration Management at Scale
- Error Handling With Block, Rescue And Always — Ansible Configuration Management at Scale
- Anatomy Of A Playbook: Plays, Tasks And Modules — RHCE in Ansible (EX294): Automate Red Hat Systems
- Facts And Magic Variables: Let Each Node Describe Itself — RHCE in Ansible (EX294): Automate Red Hat Systems
- Loops: One Task, Many Items — RHCE in Ansible (EX294): Automate Red Hat Systems
- Roles: The Directory Ansible Expects, Defaults And Handlers — RHCE in Ansible (EX294): Automate Red Hat Systems
- Packages And Repositories: yum_repository And dnf — RHCE in Ansible (EX294): Automate Red Hat Systems
- Users And Groups From A List, With Passwords That Settle — RHCE in Ansible (EX294): Automate Red Hat Systems
- Jinja Templates: One File, A Different Text Per Host — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: A Web Node From A Ticket — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: Storage Only Where The Disk Exists — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: People, Passwords And sudo From The Vault — RHCE in Ansible (EX294): Automate Red Hat Systems