Ansible register stdout_lines

Hi team

Need your support I’m looking out for put loop on register stdout _lines
my stdout_lines output is this

“stdout_lines”: [
“NAME READY STATUS RESTARTS AGE”,
“kafka-0 1/1 Running 3 (3h1m ago) 3d”,
“kafka-1 1/1 Running 3 (3h1m ago) 3d”,
“kafka-zookeeper-0 1/1 Running 1 (3h2m ago) 3d”
]

My playbook task is this

  • name: List of {{release_name}} pods
    shell: kubectl get pods -l ‘app.kubernetes.io/component in (zookeeper,kafka)’
    register: pod_output
    when: pod_status is succeeded
  • debug:
    var: pod_output.stdout_lines

Output:

“pod_output”: {
“changed”: true,
“cmd”: “kubectl get pods -l ‘app.kubernetes.io/component in (zookeeper,kafka)’”,
“delta”: “0:00:00.080215”,
“end”: “2022-12-19 07:35:22.925000”,
“failed”: false,
“rc”: 0,
“start”: “2022-12-19 07:35:22.844785”,
“stderr”: “”,
“stderr_lines”: ,
“stdout”: “NAME READY STATUS RESTARTS AGE\nkafka-0 1/1 Running 3 (3h1m ago) 3d\nkafka-1 1/1 Running 3 (3h1m ago) 3d\nkafka-zookeeper-
0 1/1 Running 1 (3h2m ago) 3d”,
“stdout_lines”: [
“NAME READY STATUS RESTARTS AGE”,
“kafka-0 1/1 Running 3 (3h1m ago) 3d”,
“kafka-1 1/1 Running 3 (3h1m ago) 3d”,
“kafka-zookeeper-0 1/1 Running 1 (3h2m ago) 3d”
]
}
}

Now i want to put loop or with_items on the stdout_lines to check the status of running if it is not running i will get a result

How can i achieve this with the help of loop or with_items.
Stdout_lines are list but when i’m trying it it showing me {“msg”: “‘dict object’ has no attribute ‘stdout’”}

How can I achieve this can you please help me

Hii

You're trying to parse the standard format, which is not meant to be parsed.
Instead use the json output option of kubectl.