LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

Should new playbooks use loop or the with_* keywords, and why do you still need to understand with_items?

Write new loops with loop (recommended since Ansible 2.5), but be able to read with_items, because a lot of existing playbooks and roles still use it.

loop is one keyword with one behaviour; the with_* family is a set of keywords each tied to a lookup plugin, with small differences such as the implicit flattening of with_items. The with_* syntax is not deprecated yet but is expected to be at some point, so new code should not add to it.

You still need to read it: Ansible Galaxy roles, older company playbooks and many online examples were written before 2.5. Every with_* task can be rewritten as loop combined with a filter or query(), and the official migration table shows the equivalent for each keyword. For simple iteration, either keyword does the job.

Go deeper:

From Quiz: ITIA / Ansible Task Control: Loops, Conditionals, Handlers and Error Handling | Updated: Nov 12, 2026