LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

How can a later task process every per-item result of an earlier looped task?

Loop over the registered variable's results list: loop: "{{ echo_results['results'] }}", then read each entry's fields as item['stdout'].

Because the per-iteration outcomes sit in a list, a second task can iterate over that list. On each pass, item is no longer the original value (one) but the whole result dictionary of that iteration:

- name: Show stdout from the previous task.
  ansible.builtin.debug:
    msg: "STDOUT from previous task: {{ item['stdout'] }}"
  loop: "{{ echo_results['results'] }}"

Output: STDOUT from previous task: This is my item: one, then the same for two. Ansible also prints the full result dictionary as the loop label of each pass, which is why the output is long; loop_control: label: "{{ item['item'] }}" keeps it readable.

This pattern (run, register, iterate over results) is how you react per item, for example by only acting on the iterations where item['rc'] != 0.

Go deeper:

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