How to isolate ansible output based on key

I am trying to isolate the output of the ansible playbook however it says "output.stdout": "VARIABLE IS NOT DEFINED!"

My playbook code is: --- - hosts: localhost tasks: - name: Register variable shell: "echo {{ item }}" loop: - "one" - "two" register: output - debug: var: output.stdout

Interestingly , the debug output works fine if i dont isolate it using stdout key.

TASK [Register variable] ***********************************************************************************************************************************************
changed: [localhost] => (item=one)
changed: [localhost] => (item=two)

TASK [debug] ***********************************************************************************************************************************************************
ok: [localhost] => {
    "output": {
        "changed": true,
        "msg": "All items completed",
        "results": [
            {
                "ansible_loop_var": "item",
                "changed": true,
                "cmd": "echo one",
                "delta": "0:00:00.002986",
                "end": "2020-01-24 00:20:57.226744",
                "failed": false,
                "invocation": {
                    "module_args": {
                        "_raw_params": "echo one",
                        "_uses_shell": true,
                        "argv": null,
                        "chdir": null,
                        "creates": null,

What am i doing wrong ?


https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#registering-variables-with-a-loop

When you use register with a loop, the data structure placed in the variable will contain a results attribute that is a list of all responses from the module

Thus:

output.results[0].stdout
output.results[1].stdout