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.
* 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": trueand"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:
Registering variables with a loop (official docs) โ the
resultsstructure and how to use it.