LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

Besides a plain list, what other kinds of things can an Ansible loop repeat a task over?

  • each element of a list (strings or dictionaries)
  • the contents of files named in a list
  • a generated sequence of numbers
  • more complex structures (nested lists, dictionaries)

These four cases map onto the older with_* keywords, each of which was backed by a lookup plugin (a plugin that fetches data on the control node):

Case Older keyword What item holds each pass
A list of values with_items one list element
Files on the control node with_file the content of one file
A numeric sequence with_sequence one generated number

With the modern loop keyword, the special cases are expressed by feeding loop a list built with a filter or lookup, for example loop: "{{ query('sequence', 'start=1 end=5') }}" or loop: "{{ range(1, 6) | list }}". Simple lists, which cover most day-to-day automation, need nothing extra.

Go deeper:

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