LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

What does register capture when the task has a loop, and how is the result structured?

One variable that holds a summary plus a results list with one entry per iteration; each entry has that pass's item, rc, stdout, changed and so on.

Structure of a registered loop result: top-level changed and msg, then a results list with one dictionary per item

* A looped task registers one dictionary; the per-item results sit in its results list. *

Without a loop, register stores one result dictionary. With a loop there is one module run per element, so Ansible wraps them:

- name: Looping Echo Task
  ansible.builtin.shell: "echo This is my item: {{ item }}"
  loop:
    - one
    - two
  register: echo_results

Printing echo_results with debug shows:

  • top-level keys such as "changed": true and "msg": "All items completed";
  • "results": [ ... ], a list (opened by [) with one dictionary per iteration;
  • in each dictionary, "item": "one" (which element this was), "rc": 0, "stdout": "This is my item: one", "ansible_loop_var": "item", timing fields and more.

The common mistake is to write echo_results.stdout: that key does not exist on a looped result. The output is per item, at echo_results['results'][0]['stdout'].

Go deeper:

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